documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4932. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var clipPlaneFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragment: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var morphTargetsVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var instancesVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var bonesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var clipPlaneVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var shadowMapVertexShader: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var depthBoxBlurPixelShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * Class representing a ray with position and direction
  9453. */
  9454. export class Ray {
  9455. /** origin point */
  9456. origin: Vector3;
  9457. /** direction */
  9458. direction: Vector3;
  9459. /** length of the ray */
  9460. length: number;
  9461. private static readonly TmpVector3;
  9462. private _tmpRay;
  9463. /**
  9464. * Creates a new ray
  9465. * @param origin origin point
  9466. * @param direction direction
  9467. * @param length length of the ray
  9468. */
  9469. constructor(
  9470. /** origin point */
  9471. origin: Vector3,
  9472. /** direction */
  9473. direction: Vector3,
  9474. /** length of the ray */
  9475. length?: number);
  9476. /**
  9477. * Checks if the ray intersects a box
  9478. * @param minimum bound of the box
  9479. * @param maximum bound of the box
  9480. * @param intersectionTreshold extra extend to be added to the box in all direction
  9481. * @returns if the box was hit
  9482. */
  9483. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9484. /**
  9485. * Checks if the ray intersects a box
  9486. * @param box the bounding box to check
  9487. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9488. * @returns if the box was hit
  9489. */
  9490. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9491. /**
  9492. * If the ray hits a sphere
  9493. * @param sphere the bounding sphere to check
  9494. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9495. * @returns true if it hits the sphere
  9496. */
  9497. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9498. /**
  9499. * If the ray hits a triange
  9500. * @param vertex0 triangle vertex
  9501. * @param vertex1 triangle vertex
  9502. * @param vertex2 triangle vertex
  9503. * @returns intersection information if hit
  9504. */
  9505. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9506. /**
  9507. * Checks if ray intersects a plane
  9508. * @param plane the plane to check
  9509. * @returns the distance away it was hit
  9510. */
  9511. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9512. /**
  9513. * Calculate the intercept of a ray on a given axis
  9514. * @param axis to check 'x' | 'y' | 'z'
  9515. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9516. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9517. */
  9518. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9519. /**
  9520. * Checks if ray intersects a mesh
  9521. * @param mesh the mesh to check
  9522. * @param fastCheck if only the bounding box should checked
  9523. * @returns picking info of the intersecton
  9524. */
  9525. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9526. /**
  9527. * Checks if ray intersects a mesh
  9528. * @param meshes the meshes to check
  9529. * @param fastCheck if only the bounding box should checked
  9530. * @param results array to store result in
  9531. * @returns Array of picking infos
  9532. */
  9533. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9534. private _comparePickingInfo;
  9535. private static smallnum;
  9536. private static rayl;
  9537. /**
  9538. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9539. * @param sega the first point of the segment to test the intersection against
  9540. * @param segb the second point of the segment to test the intersection against
  9541. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9542. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9543. */
  9544. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9545. /**
  9546. * Update the ray from viewport position
  9547. * @param x position
  9548. * @param y y position
  9549. * @param viewportWidth viewport width
  9550. * @param viewportHeight viewport height
  9551. * @param world world matrix
  9552. * @param view view matrix
  9553. * @param projection projection matrix
  9554. * @returns this ray updated
  9555. */
  9556. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9557. /**
  9558. * Creates a ray with origin and direction of 0,0,0
  9559. * @returns the new ray
  9560. */
  9561. static Zero(): Ray;
  9562. /**
  9563. * Creates a new ray from screen space and viewport
  9564. * @param x position
  9565. * @param y y position
  9566. * @param viewportWidth viewport width
  9567. * @param viewportHeight viewport height
  9568. * @param world world matrix
  9569. * @param view view matrix
  9570. * @param projection projection matrix
  9571. * @returns new ray
  9572. */
  9573. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9576. * transformed to the given world matrix.
  9577. * @param origin The origin point
  9578. * @param end The end point
  9579. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9580. * @returns the new ray
  9581. */
  9582. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9583. /**
  9584. * Transforms a ray by a matrix
  9585. * @param ray ray to transform
  9586. * @param matrix matrix to apply
  9587. * @returns the resulting new ray
  9588. */
  9589. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9590. /**
  9591. * Transforms a ray by a matrix
  9592. * @param ray ray to transform
  9593. * @param matrix matrix to apply
  9594. * @param result ray to store result in
  9595. */
  9596. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9597. /**
  9598. * Unproject a ray from screen space to object space
  9599. * @param sourceX defines the screen space x coordinate to use
  9600. * @param sourceY defines the screen space y coordinate to use
  9601. * @param viewportWidth defines the current width of the viewport
  9602. * @param viewportHeight defines the current height of the viewport
  9603. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9604. * @param view defines the view matrix to use
  9605. * @param projection defines the projection matrix to use
  9606. */
  9607. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9608. }
  9609. /**
  9610. * Type used to define predicate used to select faces when a mesh intersection is detected
  9611. */
  9612. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9613. interface Scene {
  9614. /** @hidden */
  9615. _tempPickingRay: Nullable<Ray>;
  9616. /** @hidden */
  9617. _cachedRayForTransform: Ray;
  9618. /** @hidden */
  9619. _pickWithRayInverseMatrix: Matrix;
  9620. /** @hidden */
  9621. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9622. /** @hidden */
  9623. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9624. }
  9625. }
  9626. declare module BABYLON {
  9627. /**
  9628. * Groups all the scene component constants in one place to ease maintenance.
  9629. * @hidden
  9630. */
  9631. export class SceneComponentConstants {
  9632. static readonly NAME_EFFECTLAYER: string;
  9633. static readonly NAME_LAYER: string;
  9634. static readonly NAME_LENSFLARESYSTEM: string;
  9635. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9636. static readonly NAME_PARTICLESYSTEM: string;
  9637. static readonly NAME_GAMEPAD: string;
  9638. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9639. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9640. static readonly NAME_DEPTHRENDERER: string;
  9641. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9642. static readonly NAME_SPRITE: string;
  9643. static readonly NAME_OUTLINERENDERER: string;
  9644. static readonly NAME_PROCEDURALTEXTURE: string;
  9645. static readonly NAME_SHADOWGENERATOR: string;
  9646. static readonly NAME_OCTREE: string;
  9647. static readonly NAME_PHYSICSENGINE: string;
  9648. static readonly NAME_AUDIO: string;
  9649. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9650. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9653. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9654. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9655. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9656. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9657. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9658. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9659. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9660. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9661. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9662. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9663. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9664. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9665. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9666. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9667. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9668. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9669. static readonly STEP_AFTERRENDER_AUDIO: number;
  9670. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9671. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9672. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9673. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9674. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9675. static readonly STEP_POINTERMOVE_SPRITE: number;
  9676. static readonly STEP_POINTERDOWN_SPRITE: number;
  9677. static readonly STEP_POINTERUP_SPRITE: number;
  9678. }
  9679. /**
  9680. * This represents a scene component.
  9681. *
  9682. * This is used to decouple the dependency the scene is having on the different workloads like
  9683. * layers, post processes...
  9684. */
  9685. export interface ISceneComponent {
  9686. /**
  9687. * The name of the component. Each component must have a unique name.
  9688. */
  9689. name: string;
  9690. /**
  9691. * The scene the component belongs to.
  9692. */
  9693. scene: Scene;
  9694. /**
  9695. * Register the component to one instance of a scene.
  9696. */
  9697. register(): void;
  9698. /**
  9699. * Rebuilds the elements related to this component in case of
  9700. * context lost for instance.
  9701. */
  9702. rebuild(): void;
  9703. /**
  9704. * Disposes the component and the associated ressources.
  9705. */
  9706. dispose(): void;
  9707. }
  9708. /**
  9709. * This represents a SERIALIZABLE scene component.
  9710. *
  9711. * This extends Scene Component to add Serialization methods on top.
  9712. */
  9713. export interface ISceneSerializableComponent extends ISceneComponent {
  9714. /**
  9715. * Adds all the elements from the container to the scene
  9716. * @param container the container holding the elements
  9717. */
  9718. addFromContainer(container: AbstractScene): void;
  9719. /**
  9720. * Removes all the elements in the container from the scene
  9721. * @param container contains the elements to remove
  9722. * @param dispose if the removed element should be disposed (default: false)
  9723. */
  9724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9725. /**
  9726. * Serializes the component data to the specified json object
  9727. * @param serializationObject The object to serialize to
  9728. */
  9729. serialize(serializationObject: any): void;
  9730. }
  9731. /**
  9732. * Strong typing of a Mesh related stage step action
  9733. */
  9734. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9735. /**
  9736. * Strong typing of a Evaluate Sub Mesh related stage step action
  9737. */
  9738. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9739. /**
  9740. * Strong typing of a Active Mesh related stage step action
  9741. */
  9742. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9743. /**
  9744. * Strong typing of a Camera related stage step action
  9745. */
  9746. export type CameraStageAction = (camera: Camera) => void;
  9747. /**
  9748. * Strong typing of a Camera Frame buffer related stage step action
  9749. */
  9750. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9751. /**
  9752. * Strong typing of a Render Target related stage step action
  9753. */
  9754. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9755. /**
  9756. * Strong typing of a RenderingGroup related stage step action
  9757. */
  9758. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9759. /**
  9760. * Strong typing of a Mesh Render related stage step action
  9761. */
  9762. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9763. /**
  9764. * Strong typing of a simple stage step action
  9765. */
  9766. export type SimpleStageAction = () => void;
  9767. /**
  9768. * Strong typing of a render target action.
  9769. */
  9770. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9771. /**
  9772. * Strong typing of a pointer move action.
  9773. */
  9774. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9775. /**
  9776. * Strong typing of a pointer up/down action.
  9777. */
  9778. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9779. /**
  9780. * Representation of a stage in the scene (Basically a list of ordered steps)
  9781. * @hidden
  9782. */
  9783. export class Stage<T extends Function> extends Array<{
  9784. index: number;
  9785. component: ISceneComponent;
  9786. action: T;
  9787. }> {
  9788. /**
  9789. * Hide ctor from the rest of the world.
  9790. * @param items The items to add.
  9791. */
  9792. private constructor();
  9793. /**
  9794. * Creates a new Stage.
  9795. * @returns A new instance of a Stage
  9796. */
  9797. static Create<T extends Function>(): Stage<T>;
  9798. /**
  9799. * Registers a step in an ordered way in the targeted stage.
  9800. * @param index Defines the position to register the step in
  9801. * @param component Defines the component attached to the step
  9802. * @param action Defines the action to launch during the step
  9803. */
  9804. registerStep(index: number, component: ISceneComponent, action: T): void;
  9805. /**
  9806. * Clears all the steps from the stage.
  9807. */
  9808. clear(): void;
  9809. }
  9810. }
  9811. declare module BABYLON {
  9812. interface Scene {
  9813. /** @hidden */
  9814. _pointerOverSprite: Nullable<Sprite>;
  9815. /** @hidden */
  9816. _pickedDownSprite: Nullable<Sprite>;
  9817. /** @hidden */
  9818. _tempSpritePickingRay: Nullable<Ray>;
  9819. /**
  9820. * All of the sprite managers added to this scene
  9821. * @see http://doc.babylonjs.com/babylon101/sprites
  9822. */
  9823. spriteManagers: Array<ISpriteManager>;
  9824. /**
  9825. * An event triggered when sprites rendering is about to start
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9829. /**
  9830. * An event triggered when sprites rendering is done
  9831. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9832. */
  9833. onAfterSpritesRenderingObservable: Observable<Scene>;
  9834. /** @hidden */
  9835. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Launch a ray to try to pick a sprite in the scene
  9837. * @param x position on screen
  9838. * @param y position on screen
  9839. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9842. * @returns a PickingInfo
  9843. */
  9844. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9845. /** Use the given ray to pick a sprite in the scene
  9846. * @param ray The ray (in world space) to use to pick meshes
  9847. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo
  9851. */
  9852. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9853. /** @hidden */
  9854. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9855. /** Launch a ray to try to pick sprites in the scene
  9856. * @param x position on screen
  9857. * @param y position on screen
  9858. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9859. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9860. * @returns a PickingInfo array
  9861. */
  9862. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9863. /** Use the given ray to pick sprites in the scene
  9864. * @param ray The ray (in world space) to use to pick meshes
  9865. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9866. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9867. * @returns a PickingInfo array
  9868. */
  9869. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9870. /**
  9871. * Force the sprite under the pointer
  9872. * @param sprite defines the sprite to use
  9873. */
  9874. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9875. /**
  9876. * Gets the sprite under the pointer
  9877. * @returns a Sprite or null if no sprite is under the pointer
  9878. */
  9879. getPointerOverSprite(): Nullable<Sprite>;
  9880. }
  9881. /**
  9882. * Defines the sprite scene component responsible to manage sprites
  9883. * in a given scene.
  9884. */
  9885. export class SpriteSceneComponent implements ISceneComponent {
  9886. /**
  9887. * The component name helpfull to identify the component in the list of scene components.
  9888. */
  9889. readonly name: string;
  9890. /**
  9891. * The scene the component belongs to.
  9892. */
  9893. scene: Scene;
  9894. /** @hidden */
  9895. private _spritePredicate;
  9896. /**
  9897. * Creates a new instance of the component for the given scene
  9898. * @param scene Defines the scene to register the component in
  9899. */
  9900. constructor(scene: Scene);
  9901. /**
  9902. * Registers the component in a given scene
  9903. */
  9904. register(): void;
  9905. /**
  9906. * Rebuilds the elements related to this component in case of
  9907. * context lost for instance.
  9908. */
  9909. rebuild(): void;
  9910. /**
  9911. * Disposes the component and the associated ressources.
  9912. */
  9913. dispose(): void;
  9914. private _pickSpriteButKeepRay;
  9915. private _pointerMove;
  9916. private _pointerDown;
  9917. private _pointerUp;
  9918. }
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var fogFragmentDeclaration: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /** @hidden */
  9929. export var fogFragment: {
  9930. name: string;
  9931. shader: string;
  9932. };
  9933. }
  9934. declare module BABYLON {
  9935. /** @hidden */
  9936. export var spritesPixelShader: {
  9937. name: string;
  9938. shader: string;
  9939. };
  9940. }
  9941. declare module BABYLON {
  9942. /** @hidden */
  9943. export var fogVertexDeclaration: {
  9944. name: string;
  9945. shader: string;
  9946. };
  9947. }
  9948. declare module BABYLON {
  9949. /** @hidden */
  9950. export var spritesVertexShader: {
  9951. name: string;
  9952. shader: string;
  9953. };
  9954. }
  9955. declare module BABYLON {
  9956. /**
  9957. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9958. */
  9959. export interface ISpriteManager extends IDisposable {
  9960. /**
  9961. * Restricts the camera to viewing objects with the same layerMask.
  9962. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9963. */
  9964. layerMask: number;
  9965. /**
  9966. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9967. */
  9968. isPickable: boolean;
  9969. /**
  9970. * Specifies the rendering group id for this mesh (0 by default)
  9971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9972. */
  9973. renderingGroupId: number;
  9974. /**
  9975. * Defines the list of sprites managed by the manager.
  9976. */
  9977. sprites: Array<Sprite>;
  9978. /**
  9979. * Tests the intersection of a sprite with a specific ray.
  9980. * @param ray The ray we are sending to test the collision
  9981. * @param camera The camera space we are sending rays in
  9982. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9983. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9984. * @returns picking info or null.
  9985. */
  9986. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9987. /**
  9988. * Intersects the sprites with a ray
  9989. * @param ray defines the ray to intersect with
  9990. * @param camera defines the current active camera
  9991. * @param predicate defines a predicate used to select candidate sprites
  9992. * @returns null if no hit or a PickingInfo array
  9993. */
  9994. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9995. /**
  9996. * Renders the list of sprites on screen.
  9997. */
  9998. render(): void;
  9999. }
  10000. /**
  10001. * Class used to manage multiple sprites on the same spritesheet
  10002. * @see http://doc.babylonjs.com/babylon101/sprites
  10003. */
  10004. export class SpriteManager implements ISpriteManager {
  10005. /** defines the manager's name */
  10006. name: string;
  10007. /** Gets the list of sprites */
  10008. sprites: Sprite[];
  10009. /** Gets or sets the rendering group id (0 by default) */
  10010. renderingGroupId: number;
  10011. /** Gets or sets camera layer mask */
  10012. layerMask: number;
  10013. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10014. fogEnabled: boolean;
  10015. /** Gets or sets a boolean indicating if the sprites are pickable */
  10016. isPickable: boolean;
  10017. /** Defines the default width of a cell in the spritesheet */
  10018. cellWidth: number;
  10019. /** Defines the default height of a cell in the spritesheet */
  10020. cellHeight: number;
  10021. /** Associative array from JSON sprite data file */
  10022. private _cellData;
  10023. /** Array of sprite names from JSON sprite data file */
  10024. private _spriteMap;
  10025. /** True when packed cell data from JSON file is ready*/
  10026. private _packedAndReady;
  10027. private _textureContent;
  10028. /**
  10029. * An event triggered when the manager is disposed.
  10030. */
  10031. onDisposeObservable: Observable<SpriteManager>;
  10032. private _onDisposeObserver;
  10033. /**
  10034. * Callback called when the manager is disposed
  10035. */
  10036. set onDispose(callback: () => void);
  10037. private _capacity;
  10038. private _fromPacked;
  10039. private _spriteTexture;
  10040. private _epsilon;
  10041. private _scene;
  10042. private _vertexData;
  10043. private _buffer;
  10044. private _vertexBuffers;
  10045. private _indexBuffer;
  10046. private _effectBase;
  10047. private _effectFog;
  10048. /**
  10049. * Gets or sets the spritesheet texture
  10050. */
  10051. get texture(): Texture;
  10052. set texture(value: Texture);
  10053. private _blendMode;
  10054. /**
  10055. * Blend mode use to render the particle, it can be any of
  10056. * the static Constants.ALPHA_x properties provided in this class.
  10057. * Default value is Constants.ALPHA_COMBINE
  10058. */
  10059. get blendMode(): number;
  10060. set blendMode(blendMode: number);
  10061. /** Disables writing to the depth buffer when rendering the sprites.
  10062. * It can be handy to disable depth writing when using textures without alpha channel
  10063. * and setting some specific blend modes.
  10064. */
  10065. disableDepthWrite: boolean;
  10066. /**
  10067. * Creates a new sprite manager
  10068. * @param name defines the manager's name
  10069. * @param imgUrl defines the sprite sheet url
  10070. * @param capacity defines the maximum allowed number of sprites
  10071. * @param cellSize defines the size of a sprite cell
  10072. * @param scene defines the hosting scene
  10073. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10074. * @param samplingMode defines the smapling mode to use with spritesheet
  10075. * @param fromPacked set to false; do not alter
  10076. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10077. */
  10078. constructor(
  10079. /** defines the manager's name */
  10080. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10081. private _makePacked;
  10082. private _appendSpriteVertex;
  10083. private _checkTextureAlpha;
  10084. /**
  10085. * Intersects the sprites with a ray
  10086. * @param ray defines the ray to intersect with
  10087. * @param camera defines the current active camera
  10088. * @param predicate defines a predicate used to select candidate sprites
  10089. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10090. * @returns null if no hit or a PickingInfo
  10091. */
  10092. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10093. /**
  10094. * Intersects the sprites with a ray
  10095. * @param ray defines the ray to intersect with
  10096. * @param camera defines the current active camera
  10097. * @param predicate defines a predicate used to select candidate sprites
  10098. * @returns null if no hit or a PickingInfo array
  10099. */
  10100. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10101. /**
  10102. * Render all child sprites
  10103. */
  10104. render(): void;
  10105. /**
  10106. * Release associated resources
  10107. */
  10108. dispose(): void;
  10109. }
  10110. }
  10111. declare module BABYLON {
  10112. /** Interface used by value gradients (color, factor, ...) */
  10113. export interface IValueGradient {
  10114. /**
  10115. * Gets or sets the gradient value (between 0 and 1)
  10116. */
  10117. gradient: number;
  10118. }
  10119. /** Class used to store color4 gradient */
  10120. export class ColorGradient implements IValueGradient {
  10121. /**
  10122. * Gets or sets the gradient value (between 0 and 1)
  10123. */
  10124. gradient: number;
  10125. /**
  10126. * Gets or sets first associated color
  10127. */
  10128. color1: Color4;
  10129. /**
  10130. * Gets or sets second associated color
  10131. */
  10132. color2?: Color4 | undefined;
  10133. /**
  10134. * Creates a new color4 gradient
  10135. * @param gradient gets or sets the gradient value (between 0 and 1)
  10136. * @param color1 gets or sets first associated color
  10137. * @param color2 gets or sets first second color
  10138. */
  10139. constructor(
  10140. /**
  10141. * Gets or sets the gradient value (between 0 and 1)
  10142. */
  10143. gradient: number,
  10144. /**
  10145. * Gets or sets first associated color
  10146. */
  10147. color1: Color4,
  10148. /**
  10149. * Gets or sets second associated color
  10150. */
  10151. color2?: Color4 | undefined);
  10152. /**
  10153. * Will get a color picked randomly between color1 and color2.
  10154. * If color2 is undefined then color1 will be used
  10155. * @param result defines the target Color4 to store the result in
  10156. */
  10157. getColorToRef(result: Color4): void;
  10158. }
  10159. /** Class used to store color 3 gradient */
  10160. export class Color3Gradient implements IValueGradient {
  10161. /**
  10162. * Gets or sets the gradient value (between 0 and 1)
  10163. */
  10164. gradient: number;
  10165. /**
  10166. * Gets or sets the associated color
  10167. */
  10168. color: Color3;
  10169. /**
  10170. * Creates a new color3 gradient
  10171. * @param gradient gets or sets the gradient value (between 0 and 1)
  10172. * @param color gets or sets associated color
  10173. */
  10174. constructor(
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number,
  10179. /**
  10180. * Gets or sets the associated color
  10181. */
  10182. color: Color3);
  10183. }
  10184. /** Class used to store factor gradient */
  10185. export class FactorGradient implements IValueGradient {
  10186. /**
  10187. * Gets or sets the gradient value (between 0 and 1)
  10188. */
  10189. gradient: number;
  10190. /**
  10191. * Gets or sets first associated factor
  10192. */
  10193. factor1: number;
  10194. /**
  10195. * Gets or sets second associated factor
  10196. */
  10197. factor2?: number | undefined;
  10198. /**
  10199. * Creates a new factor gradient
  10200. * @param gradient gets or sets the gradient value (between 0 and 1)
  10201. * @param factor1 gets or sets first associated factor
  10202. * @param factor2 gets or sets second associated factor
  10203. */
  10204. constructor(
  10205. /**
  10206. * Gets or sets the gradient value (between 0 and 1)
  10207. */
  10208. gradient: number,
  10209. /**
  10210. * Gets or sets first associated factor
  10211. */
  10212. factor1: number,
  10213. /**
  10214. * Gets or sets second associated factor
  10215. */
  10216. factor2?: number | undefined);
  10217. /**
  10218. * Will get a number picked randomly between factor1 and factor2.
  10219. * If factor2 is undefined then factor1 will be used
  10220. * @returns the picked number
  10221. */
  10222. getFactor(): number;
  10223. }
  10224. /**
  10225. * Helper used to simplify some generic gradient tasks
  10226. */
  10227. export class GradientHelper {
  10228. /**
  10229. * Gets the current gradient from an array of IValueGradient
  10230. * @param ratio defines the current ratio to get
  10231. * @param gradients defines the array of IValueGradient
  10232. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10233. */
  10234. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10235. }
  10236. }
  10237. declare module BABYLON {
  10238. /**
  10239. * Interface for the size containing width and height
  10240. */
  10241. export interface ISize {
  10242. /**
  10243. * Width
  10244. */
  10245. width: number;
  10246. /**
  10247. * Heighht
  10248. */
  10249. height: number;
  10250. }
  10251. /**
  10252. * Size containing widht and height
  10253. */
  10254. export class Size implements ISize {
  10255. /**
  10256. * Width
  10257. */
  10258. width: number;
  10259. /**
  10260. * Height
  10261. */
  10262. height: number;
  10263. /**
  10264. * Creates a Size object from the given width and height (floats).
  10265. * @param width width of the new size
  10266. * @param height height of the new size
  10267. */
  10268. constructor(width: number, height: number);
  10269. /**
  10270. * Returns a string with the Size width and height
  10271. * @returns a string with the Size width and height
  10272. */
  10273. toString(): string;
  10274. /**
  10275. * "Size"
  10276. * @returns the string "Size"
  10277. */
  10278. getClassName(): string;
  10279. /**
  10280. * Returns the Size hash code.
  10281. * @returns a hash code for a unique width and height
  10282. */
  10283. getHashCode(): number;
  10284. /**
  10285. * Updates the current size from the given one.
  10286. * @param src the given size
  10287. */
  10288. copyFrom(src: Size): void;
  10289. /**
  10290. * Updates in place the current Size from the given floats.
  10291. * @param width width of the new size
  10292. * @param height height of the new size
  10293. * @returns the updated Size.
  10294. */
  10295. copyFromFloats(width: number, height: number): Size;
  10296. /**
  10297. * Updates in place the current Size from the given floats.
  10298. * @param width width to set
  10299. * @param height height to set
  10300. * @returns the updated Size.
  10301. */
  10302. set(width: number, height: number): Size;
  10303. /**
  10304. * Multiplies the width and height by numbers
  10305. * @param w factor to multiple the width by
  10306. * @param h factor to multiple the height by
  10307. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10308. */
  10309. multiplyByFloats(w: number, h: number): Size;
  10310. /**
  10311. * Clones the size
  10312. * @returns a new Size copied from the given one.
  10313. */
  10314. clone(): Size;
  10315. /**
  10316. * True if the current Size and the given one width and height are strictly equal.
  10317. * @param other the other size to compare against
  10318. * @returns True if the current Size and the given one width and height are strictly equal.
  10319. */
  10320. equals(other: Size): boolean;
  10321. /**
  10322. * The surface of the Size : width * height (float).
  10323. */
  10324. get surface(): number;
  10325. /**
  10326. * Create a new size of zero
  10327. * @returns a new Size set to (0.0, 0.0)
  10328. */
  10329. static Zero(): Size;
  10330. /**
  10331. * Sums the width and height of two sizes
  10332. * @param otherSize size to add to this size
  10333. * @returns a new Size set as the addition result of the current Size and the given one.
  10334. */
  10335. add(otherSize: Size): Size;
  10336. /**
  10337. * Subtracts the width and height of two
  10338. * @param otherSize size to subtract to this size
  10339. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10340. */
  10341. subtract(otherSize: Size): Size;
  10342. /**
  10343. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10344. * @param start starting size to lerp between
  10345. * @param end end size to lerp between
  10346. * @param amount amount to lerp between the start and end values
  10347. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10348. */
  10349. static Lerp(start: Size, end: Size, amount: number): Size;
  10350. }
  10351. }
  10352. declare module BABYLON {
  10353. interface ThinEngine {
  10354. /**
  10355. * Creates a dynamic texture
  10356. * @param width defines the width of the texture
  10357. * @param height defines the height of the texture
  10358. * @param generateMipMaps defines if the engine should generate the mip levels
  10359. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10360. * @returns the dynamic texture inside an InternalTexture
  10361. */
  10362. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10363. /**
  10364. * Update the content of a dynamic texture
  10365. * @param texture defines the texture to update
  10366. * @param canvas defines the canvas containing the source
  10367. * @param invertY defines if data must be stored with Y axis inverted
  10368. * @param premulAlpha defines if alpha is stored as premultiplied
  10369. * @param format defines the format of the data
  10370. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10371. */
  10372. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10373. }
  10374. }
  10375. declare module BABYLON {
  10376. /**
  10377. * Helper class used to generate a canvas to manipulate images
  10378. */
  10379. export class CanvasGenerator {
  10380. /**
  10381. * Create a new canvas (or offscreen canvas depending on the context)
  10382. * @param width defines the expected width
  10383. * @param height defines the expected height
  10384. * @return a new canvas or offscreen canvas
  10385. */
  10386. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10387. }
  10388. }
  10389. declare module BABYLON {
  10390. /**
  10391. * A class extending Texture allowing drawing on a texture
  10392. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10393. */
  10394. export class DynamicTexture extends Texture {
  10395. private _generateMipMaps;
  10396. private _canvas;
  10397. private _context;
  10398. private _engine;
  10399. /**
  10400. * Creates a DynamicTexture
  10401. * @param name defines the name of the texture
  10402. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10403. * @param scene defines the scene where you want the texture
  10404. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10405. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10406. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10407. */
  10408. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10409. /**
  10410. * Get the current class name of the texture useful for serialization or dynamic coding.
  10411. * @returns "DynamicTexture"
  10412. */
  10413. getClassName(): string;
  10414. /**
  10415. * Gets the current state of canRescale
  10416. */
  10417. get canRescale(): boolean;
  10418. private _recreate;
  10419. /**
  10420. * Scales the texture
  10421. * @param ratio the scale factor to apply to both width and height
  10422. */
  10423. scale(ratio: number): void;
  10424. /**
  10425. * Resizes the texture
  10426. * @param width the new width
  10427. * @param height the new height
  10428. */
  10429. scaleTo(width: number, height: number): void;
  10430. /**
  10431. * Gets the context of the canvas used by the texture
  10432. * @returns the canvas context of the dynamic texture
  10433. */
  10434. getContext(): CanvasRenderingContext2D;
  10435. /**
  10436. * Clears the texture
  10437. */
  10438. clear(): void;
  10439. /**
  10440. * Updates the texture
  10441. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10442. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10443. */
  10444. update(invertY?: boolean, premulAlpha?: boolean): void;
  10445. /**
  10446. * Draws text onto the texture
  10447. * @param text defines the text to be drawn
  10448. * @param x defines the placement of the text from the left
  10449. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10450. * @param font defines the font to be used with font-style, font-size, font-name
  10451. * @param color defines the color used for the text
  10452. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10453. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10454. * @param update defines whether texture is immediately update (default is true)
  10455. */
  10456. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10457. /**
  10458. * Clones the texture
  10459. * @returns the clone of the texture.
  10460. */
  10461. clone(): DynamicTexture;
  10462. /**
  10463. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10464. * @returns a serialized dynamic texture object
  10465. */
  10466. serialize(): any;
  10467. /** @hidden */
  10468. _rebuild(): void;
  10469. }
  10470. }
  10471. declare module BABYLON {
  10472. interface Engine {
  10473. /**
  10474. * Creates a raw texture
  10475. * @param data defines the data to store in the texture
  10476. * @param width defines the width of the texture
  10477. * @param height defines the height of the texture
  10478. * @param format defines the format of the data
  10479. * @param generateMipMaps defines if the engine should generate the mip levels
  10480. * @param invertY defines if data must be stored with Y axis inverted
  10481. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10482. * @param compression defines the compression used (null by default)
  10483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10484. * @returns the raw texture inside an InternalTexture
  10485. */
  10486. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10487. /**
  10488. * Update a raw texture
  10489. * @param texture defines the texture to update
  10490. * @param data defines the data to store in the texture
  10491. * @param format defines the format of the data
  10492. * @param invertY defines if data must be stored with Y axis inverted
  10493. */
  10494. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10495. /**
  10496. * Update a raw texture
  10497. * @param texture defines the texture to update
  10498. * @param data defines the data to store in the texture
  10499. * @param format defines the format of the data
  10500. * @param invertY defines if data must be stored with Y axis inverted
  10501. * @param compression defines the compression used (null by default)
  10502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10503. */
  10504. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10505. /**
  10506. * Creates a new raw cube texture
  10507. * @param data defines the array of data to use to create each face
  10508. * @param size defines the size of the textures
  10509. * @param format defines the format of the data
  10510. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10511. * @param generateMipMaps defines if the engine should generate the mip levels
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10514. * @param compression defines the compression used (null by default)
  10515. * @returns the cube texture as an InternalTexture
  10516. */
  10517. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10518. /**
  10519. * Update a raw cube texture
  10520. * @param texture defines the texture to udpdate
  10521. * @param data defines the data to store
  10522. * @param format defines the data format
  10523. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. */
  10526. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10527. /**
  10528. * Update a raw cube texture
  10529. * @param texture defines the texture to udpdate
  10530. * @param data defines the data to store
  10531. * @param format defines the data format
  10532. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10533. * @param invertY defines if data must be stored with Y axis inverted
  10534. * @param compression defines the compression used (null by default)
  10535. */
  10536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10537. /**
  10538. * Update a raw cube texture
  10539. * @param texture defines the texture to udpdate
  10540. * @param data defines the data to store
  10541. * @param format defines the data format
  10542. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10543. * @param invertY defines if data must be stored with Y axis inverted
  10544. * @param compression defines the compression used (null by default)
  10545. * @param level defines which level of the texture to update
  10546. */
  10547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10548. /**
  10549. * Creates a new raw cube texture from a specified url
  10550. * @param url defines the url where the data is located
  10551. * @param scene defines the current scene
  10552. * @param size defines the size of the textures
  10553. * @param format defines the format of the data
  10554. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10555. * @param noMipmap defines if the engine should avoid generating the mip levels
  10556. * @param callback defines a callback used to extract texture data from loaded data
  10557. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10558. * @param onLoad defines a callback called when texture is loaded
  10559. * @param onError defines a callback called if there is an error
  10560. * @returns the cube texture as an InternalTexture
  10561. */
  10562. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10563. /**
  10564. * Creates a new raw cube texture from a specified url
  10565. * @param url defines the url where the data is located
  10566. * @param scene defines the current scene
  10567. * @param size defines the size of the textures
  10568. * @param format defines the format of the data
  10569. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10570. * @param noMipmap defines if the engine should avoid generating the mip levels
  10571. * @param callback defines a callback used to extract texture data from loaded data
  10572. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10573. * @param onLoad defines a callback called when texture is loaded
  10574. * @param onError defines a callback called if there is an error
  10575. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10576. * @param invertY defines if data must be stored with Y axis inverted
  10577. * @returns the cube texture as an InternalTexture
  10578. */
  10579. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10580. /**
  10581. * Creates a new raw 3D texture
  10582. * @param data defines the data used to create the texture
  10583. * @param width defines the width of the texture
  10584. * @param height defines the height of the texture
  10585. * @param depth defines the depth of the texture
  10586. * @param format defines the format of the texture
  10587. * @param generateMipMaps defines if the engine must generate mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10590. * @param compression defines the compressed used (can be null)
  10591. * @param textureType defines the compressed used (can be null)
  10592. * @returns a new raw 3D texture (stored in an InternalTexture)
  10593. */
  10594. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10595. /**
  10596. * Update a raw 3D texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store
  10599. * @param format defines the data format
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw 3D texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store
  10607. * @param format defines the data format
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the used compression (can be null)
  10610. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10611. */
  10612. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10613. /**
  10614. * Creates a new raw 2D array texture
  10615. * @param data defines the data used to create the texture
  10616. * @param width defines the width of the texture
  10617. * @param height defines the height of the texture
  10618. * @param depth defines the number of layers of the texture
  10619. * @param format defines the format of the texture
  10620. * @param generateMipMaps defines if the engine must generate mip levels
  10621. * @param invertY defines if data must be stored with Y axis inverted
  10622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10623. * @param compression defines the compressed used (can be null)
  10624. * @param textureType defines the compressed used (can be null)
  10625. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10626. */
  10627. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10628. /**
  10629. * Update a raw 2D array texture
  10630. * @param texture defines the texture to update
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param invertY defines if data must be stored with Y axis inverted
  10634. */
  10635. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10636. /**
  10637. * Update a raw 2D array texture
  10638. * @param texture defines the texture to update
  10639. * @param data defines the data to store
  10640. * @param format defines the data format
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the used compression (can be null)
  10643. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10644. */
  10645. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10646. }
  10647. }
  10648. declare module BABYLON {
  10649. /**
  10650. * Raw texture can help creating a texture directly from an array of data.
  10651. * This can be super useful if you either get the data from an uncompressed source or
  10652. * if you wish to create your texture pixel by pixel.
  10653. */
  10654. export class RawTexture extends Texture {
  10655. /**
  10656. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10657. */
  10658. format: number;
  10659. private _engine;
  10660. /**
  10661. * Instantiates a new RawTexture.
  10662. * Raw texture can help creating a texture directly from an array of data.
  10663. * This can be super useful if you either get the data from an uncompressed source or
  10664. * if you wish to create your texture pixel by pixel.
  10665. * @param data define the array of data to use to create the texture
  10666. * @param width define the width of the texture
  10667. * @param height define the height of the texture
  10668. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10669. * @param scene define the scene the texture belongs to
  10670. * @param generateMipMaps define whether mip maps should be generated or not
  10671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10674. */
  10675. constructor(data: ArrayBufferView, width: number, height: number,
  10676. /**
  10677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10678. */
  10679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10680. /**
  10681. * Updates the texture underlying data.
  10682. * @param data Define the new data of the texture
  10683. */
  10684. update(data: ArrayBufferView): void;
  10685. /**
  10686. * Creates a luminance texture from some data.
  10687. * @param data Define the texture data
  10688. * @param width Define the width of the texture
  10689. * @param height Define the height of the texture
  10690. * @param scene Define the scene the texture belongs to
  10691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10694. * @returns the luminance texture
  10695. */
  10696. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10697. /**
  10698. * Creates a luminance alpha texture from some data.
  10699. * @param data Define the texture data
  10700. * @param width Define the width of the texture
  10701. * @param height Define the height of the texture
  10702. * @param scene Define the scene the texture belongs to
  10703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10706. * @returns the luminance alpha texture
  10707. */
  10708. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10709. /**
  10710. * Creates an alpha texture from some data.
  10711. * @param data Define the texture data
  10712. * @param width Define the width of the texture
  10713. * @param height Define the height of the texture
  10714. * @param scene Define the scene the texture belongs to
  10715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10718. * @returns the alpha texture
  10719. */
  10720. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10721. /**
  10722. * Creates a RGB texture from some data.
  10723. * @param data Define the texture data
  10724. * @param width Define the width of the texture
  10725. * @param height Define the height of the texture
  10726. * @param scene Define the scene the texture belongs to
  10727. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10728. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10729. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10730. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10731. * @returns the RGB alpha texture
  10732. */
  10733. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10734. /**
  10735. * Creates a RGBA texture from some data.
  10736. * @param data Define the texture data
  10737. * @param width Define the width of the texture
  10738. * @param height Define the height of the texture
  10739. * @param scene Define the scene the texture belongs to
  10740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10744. * @returns the RGBA texture
  10745. */
  10746. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10747. /**
  10748. * Creates a R texture from some data.
  10749. * @param data Define the texture data
  10750. * @param width Define the width of the texture
  10751. * @param height Define the height of the texture
  10752. * @param scene Define the scene the texture belongs to
  10753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10757. * @returns the R texture
  10758. */
  10759. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10760. }
  10761. }
  10762. declare module BABYLON {
  10763. interface AbstractScene {
  10764. /**
  10765. * The list of procedural textures added to the scene
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10767. */
  10768. proceduralTextures: Array<ProceduralTexture>;
  10769. }
  10770. /**
  10771. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10772. * in a given scene.
  10773. */
  10774. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10775. /**
  10776. * The component name helpfull to identify the component in the list of scene components.
  10777. */
  10778. readonly name: string;
  10779. /**
  10780. * The scene the component belongs to.
  10781. */
  10782. scene: Scene;
  10783. /**
  10784. * Creates a new instance of the component for the given scene
  10785. * @param scene Defines the scene to register the component in
  10786. */
  10787. constructor(scene: Scene);
  10788. /**
  10789. * Registers the component in a given scene
  10790. */
  10791. register(): void;
  10792. /**
  10793. * Rebuilds the elements related to this component in case of
  10794. * context lost for instance.
  10795. */
  10796. rebuild(): void;
  10797. /**
  10798. * Disposes the component and the associated ressources.
  10799. */
  10800. dispose(): void;
  10801. private _beforeClear;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. interface ThinEngine {
  10806. /**
  10807. * Creates a new render target cube texture
  10808. * @param size defines the size of the texture
  10809. * @param options defines the options used to create the texture
  10810. * @returns a new render target cube texture stored in an InternalTexture
  10811. */
  10812. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10813. }
  10814. }
  10815. declare module BABYLON {
  10816. /** @hidden */
  10817. export var proceduralVertexShader: {
  10818. name: string;
  10819. shader: string;
  10820. };
  10821. }
  10822. declare module BABYLON {
  10823. /**
  10824. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10825. * This is the base class of any Procedural texture and contains most of the shareable code.
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10827. */
  10828. export class ProceduralTexture extends Texture {
  10829. isCube: boolean;
  10830. /**
  10831. * Define if the texture is enabled or not (disabled texture will not render)
  10832. */
  10833. isEnabled: boolean;
  10834. /**
  10835. * Define if the texture must be cleared before rendering (default is true)
  10836. */
  10837. autoClear: boolean;
  10838. /**
  10839. * Callback called when the texture is generated
  10840. */
  10841. onGenerated: () => void;
  10842. /**
  10843. * Event raised when the texture is generated
  10844. */
  10845. onGeneratedObservable: Observable<ProceduralTexture>;
  10846. /** @hidden */
  10847. _generateMipMaps: boolean;
  10848. /** @hidden **/
  10849. _effect: Effect;
  10850. /** @hidden */
  10851. _textures: {
  10852. [key: string]: Texture;
  10853. };
  10854. /** @hidden */
  10855. protected _fallbackTexture: Nullable<Texture>;
  10856. private _size;
  10857. private _currentRefreshId;
  10858. private _frameId;
  10859. private _refreshRate;
  10860. private _vertexBuffers;
  10861. private _indexBuffer;
  10862. private _uniforms;
  10863. private _samplers;
  10864. private _fragment;
  10865. private _floats;
  10866. private _ints;
  10867. private _floatsArrays;
  10868. private _colors3;
  10869. private _colors4;
  10870. private _vectors2;
  10871. private _vectors3;
  10872. private _matrices;
  10873. private _fallbackTextureUsed;
  10874. private _engine;
  10875. private _cachedDefines;
  10876. private _contentUpdateId;
  10877. private _contentData;
  10878. /**
  10879. * Instantiates a new procedural texture.
  10880. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  10881. * This is the base class of any Procedural texture and contains most of the shareable code.
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. * @param name Define the name of the texture
  10884. * @param size Define the size of the texture to create
  10885. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10886. * @param scene Define the scene the texture belongs to
  10887. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10888. * @param generateMipMaps Define if the texture should creates mip maps or not
  10889. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10890. */
  10891. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10892. /**
  10893. * The effect that is created when initializing the post process.
  10894. * @returns The created effect corresponding the the postprocess.
  10895. */
  10896. getEffect(): Effect;
  10897. /**
  10898. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10899. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10900. */
  10901. getContent(): Nullable<ArrayBufferView>;
  10902. private _createIndexBuffer;
  10903. /** @hidden */
  10904. _rebuild(): void;
  10905. /**
  10906. * Resets the texture in order to recreate its associated resources.
  10907. * This can be called in case of context loss
  10908. */
  10909. reset(): void;
  10910. protected _getDefines(): string;
  10911. /**
  10912. * Is the texture ready to be used ? (rendered at least once)
  10913. * @returns true if ready, otherwise, false.
  10914. */
  10915. isReady(): boolean;
  10916. /**
  10917. * Resets the refresh counter of the texture and start bak from scratch.
  10918. * Could be useful to regenerate the texture if it is setup to render only once.
  10919. */
  10920. resetRefreshCounter(): void;
  10921. /**
  10922. * Set the fragment shader to use in order to render the texture.
  10923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10924. */
  10925. setFragment(fragment: any): void;
  10926. /**
  10927. * Define the refresh rate of the texture or the rendering frequency.
  10928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10929. */
  10930. get refreshRate(): number;
  10931. set refreshRate(value: number);
  10932. /** @hidden */
  10933. _shouldRender(): boolean;
  10934. /**
  10935. * Get the size the texture is rendering at.
  10936. * @returns the size (texture is always squared)
  10937. */
  10938. getRenderSize(): number;
  10939. /**
  10940. * Resize the texture to new value.
  10941. * @param size Define the new size the texture should have
  10942. * @param generateMipMaps Define whether the new texture should create mip maps
  10943. */
  10944. resize(size: number, generateMipMaps: boolean): void;
  10945. private _checkUniform;
  10946. /**
  10947. * Set a texture in the shader program used to render.
  10948. * @param name Define the name of the uniform samplers as defined in the shader
  10949. * @param texture Define the texture to bind to this sampler
  10950. * @return the texture itself allowing "fluent" like uniform updates
  10951. */
  10952. setTexture(name: string, texture: Texture): ProceduralTexture;
  10953. /**
  10954. * Set a float in the shader.
  10955. * @param name Define the name of the uniform as defined in the shader
  10956. * @param value Define the value to give to the uniform
  10957. * @return the texture itself allowing "fluent" like uniform updates
  10958. */
  10959. setFloat(name: string, value: number): ProceduralTexture;
  10960. /**
  10961. * Set a int in the shader.
  10962. * @param name Define the name of the uniform as defined in the shader
  10963. * @param value Define the value to give to the uniform
  10964. * @return the texture itself allowing "fluent" like uniform updates
  10965. */
  10966. setInt(name: string, value: number): ProceduralTexture;
  10967. /**
  10968. * Set an array of floats in the shader.
  10969. * @param name Define the name of the uniform as defined in the shader
  10970. * @param value Define the value to give to the uniform
  10971. * @return the texture itself allowing "fluent" like uniform updates
  10972. */
  10973. setFloats(name: string, value: number[]): ProceduralTexture;
  10974. /**
  10975. * Set a vec3 in the shader from a Color3.
  10976. * @param name Define the name of the uniform as defined in the shader
  10977. * @param value Define the value to give to the uniform
  10978. * @return the texture itself allowing "fluent" like uniform updates
  10979. */
  10980. setColor3(name: string, value: Color3): ProceduralTexture;
  10981. /**
  10982. * Set a vec4 in the shader from a Color4.
  10983. * @param name Define the name of the uniform as defined in the shader
  10984. * @param value Define the value to give to the uniform
  10985. * @return the texture itself allowing "fluent" like uniform updates
  10986. */
  10987. setColor4(name: string, value: Color4): ProceduralTexture;
  10988. /**
  10989. * Set a vec2 in the shader from a Vector2.
  10990. * @param name Define the name of the uniform as defined in the shader
  10991. * @param value Define the value to give to the uniform
  10992. * @return the texture itself allowing "fluent" like uniform updates
  10993. */
  10994. setVector2(name: string, value: Vector2): ProceduralTexture;
  10995. /**
  10996. * Set a vec3 in the shader from a Vector3.
  10997. * @param name Define the name of the uniform as defined in the shader
  10998. * @param value Define the value to give to the uniform
  10999. * @return the texture itself allowing "fluent" like uniform updates
  11000. */
  11001. setVector3(name: string, value: Vector3): ProceduralTexture;
  11002. /**
  11003. * Set a mat4 in the shader from a MAtrix.
  11004. * @param name Define the name of the uniform as defined in the shader
  11005. * @param value Define the value to give to the uniform
  11006. * @return the texture itself allowing "fluent" like uniform updates
  11007. */
  11008. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11009. /**
  11010. * Render the texture to its associated render target.
  11011. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11012. */
  11013. render(useCameraPostProcess?: boolean): void;
  11014. /**
  11015. * Clone the texture.
  11016. * @returns the cloned texture
  11017. */
  11018. clone(): ProceduralTexture;
  11019. /**
  11020. * Dispose the texture and release its asoociated resources.
  11021. */
  11022. dispose(): void;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * This represents the base class for particle system in Babylon.
  11028. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11029. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11030. * @example https://doc.babylonjs.com/babylon101/particles
  11031. */
  11032. export class BaseParticleSystem {
  11033. /**
  11034. * Source color is added to the destination color without alpha affecting the result
  11035. */
  11036. static BLENDMODE_ONEONE: number;
  11037. /**
  11038. * Blend current color and particle color using particle’s alpha
  11039. */
  11040. static BLENDMODE_STANDARD: number;
  11041. /**
  11042. * Add current color and particle color multiplied by particle’s alpha
  11043. */
  11044. static BLENDMODE_ADD: number;
  11045. /**
  11046. * Multiply current color with particle color
  11047. */
  11048. static BLENDMODE_MULTIPLY: number;
  11049. /**
  11050. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11051. */
  11052. static BLENDMODE_MULTIPLYADD: number;
  11053. /**
  11054. * List of animations used by the particle system.
  11055. */
  11056. animations: Animation[];
  11057. /**
  11058. * Gets or sets the unique id of the particle system
  11059. */
  11060. uniqueId: number;
  11061. /**
  11062. * The id of the Particle system.
  11063. */
  11064. id: string;
  11065. /**
  11066. * The friendly name of the Particle system.
  11067. */
  11068. name: string;
  11069. /**
  11070. * Snippet ID if the particle system was created from the snippet server
  11071. */
  11072. snippetId: string;
  11073. /**
  11074. * The rendering group used by the Particle system to chose when to render.
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * The emitter represents the Mesh or position we are attaching the particle system to.
  11079. */
  11080. emitter: Nullable<AbstractMesh | Vector3>;
  11081. /**
  11082. * The maximum number of particles to emit per frame
  11083. */
  11084. emitRate: number;
  11085. /**
  11086. * If you want to launch only a few particles at once, that can be done, as well.
  11087. */
  11088. manualEmitCount: number;
  11089. /**
  11090. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11091. */
  11092. updateSpeed: number;
  11093. /**
  11094. * The amount of time the particle system is running (depends of the overall update speed).
  11095. */
  11096. targetStopDuration: number;
  11097. /**
  11098. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11099. */
  11100. disposeOnStop: boolean;
  11101. /**
  11102. * Minimum power of emitting particles.
  11103. */
  11104. minEmitPower: number;
  11105. /**
  11106. * Maximum power of emitting particles.
  11107. */
  11108. maxEmitPower: number;
  11109. /**
  11110. * Minimum life time of emitting particles.
  11111. */
  11112. minLifeTime: number;
  11113. /**
  11114. * Maximum life time of emitting particles.
  11115. */
  11116. maxLifeTime: number;
  11117. /**
  11118. * Minimum Size of emitting particles.
  11119. */
  11120. minSize: number;
  11121. /**
  11122. * Maximum Size of emitting particles.
  11123. */
  11124. maxSize: number;
  11125. /**
  11126. * Minimum scale of emitting particles on X axis.
  11127. */
  11128. minScaleX: number;
  11129. /**
  11130. * Maximum scale of emitting particles on X axis.
  11131. */
  11132. maxScaleX: number;
  11133. /**
  11134. * Minimum scale of emitting particles on Y axis.
  11135. */
  11136. minScaleY: number;
  11137. /**
  11138. * Maximum scale of emitting particles on Y axis.
  11139. */
  11140. maxScaleY: number;
  11141. /**
  11142. * Gets or sets the minimal initial rotation in radians.
  11143. */
  11144. minInitialRotation: number;
  11145. /**
  11146. * Gets or sets the maximal initial rotation in radians.
  11147. */
  11148. maxInitialRotation: number;
  11149. /**
  11150. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11151. */
  11152. minAngularSpeed: number;
  11153. /**
  11154. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11155. */
  11156. maxAngularSpeed: number;
  11157. /**
  11158. * The texture used to render each particle. (this can be a spritesheet)
  11159. */
  11160. particleTexture: Nullable<Texture>;
  11161. /**
  11162. * The layer mask we are rendering the particles through.
  11163. */
  11164. layerMask: number;
  11165. /**
  11166. * This can help using your own shader to render the particle system.
  11167. * The according effect will be created
  11168. */
  11169. customShader: any;
  11170. /**
  11171. * By default particle system starts as soon as they are created. This prevents the
  11172. * automatic start to happen and let you decide when to start emitting particles.
  11173. */
  11174. preventAutoStart: boolean;
  11175. private _noiseTexture;
  11176. /**
  11177. * Gets or sets a texture used to add random noise to particle positions
  11178. */
  11179. get noiseTexture(): Nullable<ProceduralTexture>;
  11180. set noiseTexture(value: Nullable<ProceduralTexture>);
  11181. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11182. noiseStrength: Vector3;
  11183. /**
  11184. * Callback triggered when the particle animation is ending.
  11185. */
  11186. onAnimationEnd: Nullable<() => void>;
  11187. /**
  11188. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11189. */
  11190. blendMode: number;
  11191. /**
  11192. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11193. * to override the particles.
  11194. */
  11195. forceDepthWrite: boolean;
  11196. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11197. preWarmCycles: number;
  11198. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11199. preWarmStepOffset: number;
  11200. /**
  11201. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11202. */
  11203. spriteCellChangeSpeed: number;
  11204. /**
  11205. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11206. */
  11207. startSpriteCellID: number;
  11208. /**
  11209. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11210. */
  11211. endSpriteCellID: number;
  11212. /**
  11213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11214. */
  11215. spriteCellWidth: number;
  11216. /**
  11217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11218. */
  11219. spriteCellHeight: number;
  11220. /**
  11221. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11222. */
  11223. spriteRandomStartCell: boolean;
  11224. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11225. translationPivot: Vector2;
  11226. /** @hidden */
  11227. protected _isAnimationSheetEnabled: boolean;
  11228. /**
  11229. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11230. */
  11231. beginAnimationOnStart: boolean;
  11232. /**
  11233. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11234. */
  11235. beginAnimationFrom: number;
  11236. /**
  11237. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11238. */
  11239. beginAnimationTo: number;
  11240. /**
  11241. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11242. */
  11243. beginAnimationLoop: boolean;
  11244. /**
  11245. * Gets or sets a world offset applied to all particles
  11246. */
  11247. worldOffset: Vector3;
  11248. /**
  11249. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11250. */
  11251. get isAnimationSheetEnabled(): boolean;
  11252. set isAnimationSheetEnabled(value: boolean);
  11253. /**
  11254. * Get hosting scene
  11255. * @returns the scene
  11256. */
  11257. getScene(): Scene;
  11258. /**
  11259. * You can use gravity if you want to give an orientation to your particles.
  11260. */
  11261. gravity: Vector3;
  11262. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11263. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11264. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11265. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11266. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11267. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11268. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11269. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11270. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11271. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11272. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11273. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11274. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11275. /**
  11276. * Defines the delay in milliseconds before starting the system (0 by default)
  11277. */
  11278. startDelay: number;
  11279. /**
  11280. * Gets the current list of drag gradients.
  11281. * You must use addDragGradient and removeDragGradient to udpate this list
  11282. * @returns the list of drag gradients
  11283. */
  11284. getDragGradients(): Nullable<Array<FactorGradient>>;
  11285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11286. limitVelocityDamping: number;
  11287. /**
  11288. * Gets the current list of limit velocity gradients.
  11289. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11290. * @returns the list of limit velocity gradients
  11291. */
  11292. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11293. /**
  11294. * Gets the current list of color gradients.
  11295. * You must use addColorGradient and removeColorGradient to udpate this list
  11296. * @returns the list of color gradients
  11297. */
  11298. getColorGradients(): Nullable<Array<ColorGradient>>;
  11299. /**
  11300. * Gets the current list of size gradients.
  11301. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11302. * @returns the list of size gradients
  11303. */
  11304. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11305. /**
  11306. * Gets the current list of color remap gradients.
  11307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11308. * @returns the list of color remap gradients
  11309. */
  11310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11311. /**
  11312. * Gets the current list of alpha remap gradients.
  11313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11314. * @returns the list of alpha remap gradients
  11315. */
  11316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11317. /**
  11318. * Gets the current list of life time gradients.
  11319. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11320. * @returns the list of life time gradients
  11321. */
  11322. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11323. /**
  11324. * Gets the current list of angular speed gradients.
  11325. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11326. * @returns the list of angular speed gradients
  11327. */
  11328. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11329. /**
  11330. * Gets the current list of velocity gradients.
  11331. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11332. * @returns the list of velocity gradients
  11333. */
  11334. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11335. /**
  11336. * Gets the current list of start size gradients.
  11337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11338. * @returns the list of start size gradients
  11339. */
  11340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11341. /**
  11342. * Gets the current list of emit rate gradients.
  11343. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11344. * @returns the list of emit rate gradients
  11345. */
  11346. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11347. /**
  11348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11350. */
  11351. get direction1(): Vector3;
  11352. set direction1(value: Vector3);
  11353. /**
  11354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11356. */
  11357. get direction2(): Vector3;
  11358. set direction2(value: Vector3);
  11359. /**
  11360. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11362. */
  11363. get minEmitBox(): Vector3;
  11364. set minEmitBox(value: Vector3);
  11365. /**
  11366. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11368. */
  11369. get maxEmitBox(): Vector3;
  11370. set maxEmitBox(value: Vector3);
  11371. /**
  11372. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11373. */
  11374. color1: Color4;
  11375. /**
  11376. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11377. */
  11378. color2: Color4;
  11379. /**
  11380. * Color the particle will have at the end of its lifetime
  11381. */
  11382. colorDead: Color4;
  11383. /**
  11384. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11385. */
  11386. textureMask: Color4;
  11387. /**
  11388. * The particle emitter type defines the emitter used by the particle system.
  11389. * It can be for example box, sphere, or cone...
  11390. */
  11391. particleEmitterType: IParticleEmitterType;
  11392. /** @hidden */
  11393. _isSubEmitter: boolean;
  11394. /**
  11395. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11396. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11397. */
  11398. billboardMode: number;
  11399. protected _isBillboardBased: boolean;
  11400. /**
  11401. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11402. */
  11403. get isBillboardBased(): boolean;
  11404. set isBillboardBased(value: boolean);
  11405. /**
  11406. * The scene the particle system belongs to.
  11407. */
  11408. protected _scene: Scene;
  11409. /**
  11410. * Local cache of defines for image processing.
  11411. */
  11412. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11413. /**
  11414. * Default configuration related to image processing available in the standard Material.
  11415. */
  11416. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11417. /**
  11418. * Gets the image processing configuration used either in this material.
  11419. */
  11420. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11421. /**
  11422. * Sets the Default image processing configuration used either in the this material.
  11423. *
  11424. * If sets to null, the scene one is in use.
  11425. */
  11426. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11427. /**
  11428. * Attaches a new image processing configuration to the Standard Material.
  11429. * @param configuration
  11430. */
  11431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11432. /** @hidden */
  11433. protected _reset(): void;
  11434. /** @hidden */
  11435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11436. /**
  11437. * Instantiates a particle system.
  11438. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11439. * @param name The name of the particle system
  11440. */
  11441. constructor(name: string);
  11442. /**
  11443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11446. * @returns the emitter
  11447. */
  11448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11449. /**
  11450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11451. * @param radius The radius of the hemisphere to emit from
  11452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11453. * @returns the emitter
  11454. */
  11455. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11456. /**
  11457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11458. * @param radius The radius of the sphere to emit from
  11459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11460. * @returns the emitter
  11461. */
  11462. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11463. /**
  11464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11465. * @param radius The radius of the sphere to emit from
  11466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11468. * @returns the emitter
  11469. */
  11470. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11471. /**
  11472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11473. * @param radius The radius of the emission cylinder
  11474. * @param height The height of the emission cylinder
  11475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11477. * @returns the emitter
  11478. */
  11479. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11480. /**
  11481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11482. * @param radius The radius of the cylinder to emit from
  11483. * @param height The height of the emission cylinder
  11484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11487. * @returns the emitter
  11488. */
  11489. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11490. /**
  11491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11492. * @param radius The radius of the cone to emit from
  11493. * @param angle The base angle of the cone
  11494. * @returns the emitter
  11495. */
  11496. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11497. /**
  11498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11503. * @returns the emitter
  11504. */
  11505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11506. }
  11507. }
  11508. declare module BABYLON {
  11509. /**
  11510. * Type of sub emitter
  11511. */
  11512. export enum SubEmitterType {
  11513. /**
  11514. * Attached to the particle over it's lifetime
  11515. */
  11516. ATTACHED = 0,
  11517. /**
  11518. * Created when the particle dies
  11519. */
  11520. END = 1
  11521. }
  11522. /**
  11523. * Sub emitter class used to emit particles from an existing particle
  11524. */
  11525. export class SubEmitter {
  11526. /**
  11527. * the particle system to be used by the sub emitter
  11528. */
  11529. particleSystem: ParticleSystem;
  11530. /**
  11531. * Type of the submitter (Default: END)
  11532. */
  11533. type: SubEmitterType;
  11534. /**
  11535. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11536. * Note: This only is supported when using an emitter of type Mesh
  11537. */
  11538. inheritDirection: boolean;
  11539. /**
  11540. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11541. */
  11542. inheritedVelocityAmount: number;
  11543. /**
  11544. * Creates a sub emitter
  11545. * @param particleSystem the particle system to be used by the sub emitter
  11546. */
  11547. constructor(
  11548. /**
  11549. * the particle system to be used by the sub emitter
  11550. */
  11551. particleSystem: ParticleSystem);
  11552. /**
  11553. * Clones the sub emitter
  11554. * @returns the cloned sub emitter
  11555. */
  11556. clone(): SubEmitter;
  11557. /**
  11558. * Serialize current object to a JSON object
  11559. * @returns the serialized object
  11560. */
  11561. serialize(): any;
  11562. /** @hidden */
  11563. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11564. /**
  11565. * Creates a new SubEmitter from a serialized JSON version
  11566. * @param serializationObject defines the JSON object to read from
  11567. * @param scene defines the hosting scene
  11568. * @param rootUrl defines the rootUrl for data loading
  11569. * @returns a new SubEmitter
  11570. */
  11571. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11572. /** Release associated resources */
  11573. dispose(): void;
  11574. }
  11575. }
  11576. declare module BABYLON {
  11577. /** @hidden */
  11578. export var imageProcessingDeclaration: {
  11579. name: string;
  11580. shader: string;
  11581. };
  11582. }
  11583. declare module BABYLON {
  11584. /** @hidden */
  11585. export var imageProcessingFunctions: {
  11586. name: string;
  11587. shader: string;
  11588. };
  11589. }
  11590. declare module BABYLON {
  11591. /** @hidden */
  11592. export var particlesPixelShader: {
  11593. name: string;
  11594. shader: string;
  11595. };
  11596. }
  11597. declare module BABYLON {
  11598. /** @hidden */
  11599. export var particlesVertexShader: {
  11600. name: string;
  11601. shader: string;
  11602. };
  11603. }
  11604. declare module BABYLON {
  11605. /**
  11606. * This represents a particle system in Babylon.
  11607. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11608. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11609. * @example https://doc.babylonjs.com/babylon101/particles
  11610. */
  11611. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11612. /**
  11613. * Billboard mode will only apply to Y axis
  11614. */
  11615. static readonly BILLBOARDMODE_Y: number;
  11616. /**
  11617. * Billboard mode will apply to all axes
  11618. */
  11619. static readonly BILLBOARDMODE_ALL: number;
  11620. /**
  11621. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11622. */
  11623. static readonly BILLBOARDMODE_STRETCHED: number;
  11624. /**
  11625. * This function can be defined to provide custom update for active particles.
  11626. * This function will be called instead of regular update (age, position, color, etc.).
  11627. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11628. */
  11629. updateFunction: (particles: Particle[]) => void;
  11630. private _emitterWorldMatrix;
  11631. /**
  11632. * This function can be defined to specify initial direction for every new particle.
  11633. * It by default use the emitterType defined function
  11634. */
  11635. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11636. /**
  11637. * This function can be defined to specify initial position for every new particle.
  11638. * It by default use the emitterType defined function
  11639. */
  11640. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11641. /**
  11642. * @hidden
  11643. */
  11644. _inheritedVelocityOffset: Vector3;
  11645. /**
  11646. * An event triggered when the system is disposed
  11647. */
  11648. onDisposeObservable: Observable<ParticleSystem>;
  11649. private _onDisposeObserver;
  11650. /**
  11651. * Sets a callback that will be triggered when the system is disposed
  11652. */
  11653. set onDispose(callback: () => void);
  11654. private _particles;
  11655. private _epsilon;
  11656. private _capacity;
  11657. private _stockParticles;
  11658. private _newPartsExcess;
  11659. private _vertexData;
  11660. private _vertexBuffer;
  11661. private _vertexBuffers;
  11662. private _spriteBuffer;
  11663. private _indexBuffer;
  11664. private _effect;
  11665. private _customEffect;
  11666. private _cachedDefines;
  11667. private _scaledColorStep;
  11668. private _colorDiff;
  11669. private _scaledDirection;
  11670. private _scaledGravity;
  11671. private _currentRenderId;
  11672. private _alive;
  11673. private _useInstancing;
  11674. private _started;
  11675. private _stopped;
  11676. private _actualFrame;
  11677. private _scaledUpdateSpeed;
  11678. private _vertexBufferSize;
  11679. /** @hidden */
  11680. _currentEmitRateGradient: Nullable<FactorGradient>;
  11681. /** @hidden */
  11682. _currentEmitRate1: number;
  11683. /** @hidden */
  11684. _currentEmitRate2: number;
  11685. /** @hidden */
  11686. _currentStartSizeGradient: Nullable<FactorGradient>;
  11687. /** @hidden */
  11688. _currentStartSize1: number;
  11689. /** @hidden */
  11690. _currentStartSize2: number;
  11691. private readonly _rawTextureWidth;
  11692. private _rampGradientsTexture;
  11693. private _useRampGradients;
  11694. /** Gets or sets a boolean indicating that ramp gradients must be used
  11695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11696. */
  11697. get useRampGradients(): boolean;
  11698. set useRampGradients(value: boolean);
  11699. /**
  11700. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11701. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11702. */
  11703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11704. private _subEmitters;
  11705. /**
  11706. * @hidden
  11707. * If the particle systems emitter should be disposed when the particle system is disposed
  11708. */
  11709. _disposeEmitterOnDispose: boolean;
  11710. /**
  11711. * The current active Sub-systems, this property is used by the root particle system only.
  11712. */
  11713. activeSubSystems: Array<ParticleSystem>;
  11714. /**
  11715. * Specifies if the particles are updated in emitter local space or world space
  11716. */
  11717. isLocal: boolean;
  11718. private _rootParticleSystem;
  11719. /**
  11720. * Gets the current list of active particles
  11721. */
  11722. get particles(): Particle[];
  11723. /**
  11724. * Gets the number of particles active at the same time.
  11725. * @returns The number of active particles.
  11726. */
  11727. getActiveCount(): number;
  11728. /**
  11729. * Returns the string "ParticleSystem"
  11730. * @returns a string containing the class name
  11731. */
  11732. getClassName(): string;
  11733. /**
  11734. * Gets a boolean indicating that the system is stopping
  11735. * @returns true if the system is currently stopping
  11736. */
  11737. isStopping(): boolean;
  11738. /**
  11739. * Instantiates a particle system.
  11740. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11741. * @param name The name of the particle system
  11742. * @param capacity The max number of particles alive at the same time
  11743. * @param scene The scene the particle system belongs to
  11744. * @param customEffect a custom effect used to change the way particles are rendered by default
  11745. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11746. * @param epsilon Offset used to render the particles
  11747. */
  11748. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11749. private _addFactorGradient;
  11750. private _removeFactorGradient;
  11751. /**
  11752. * Adds a new life time gradient
  11753. * @param gradient defines the gradient to use (between 0 and 1)
  11754. * @param factor defines the life time factor to affect to the specified gradient
  11755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11756. * @returns the current particle system
  11757. */
  11758. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11759. /**
  11760. * Remove a specific life time gradient
  11761. * @param gradient defines the gradient to remove
  11762. * @returns the current particle system
  11763. */
  11764. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11765. /**
  11766. * Adds a new size gradient
  11767. * @param gradient defines the gradient to use (between 0 and 1)
  11768. * @param factor defines the size factor to affect to the specified gradient
  11769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11770. * @returns the current particle system
  11771. */
  11772. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11773. /**
  11774. * Remove a specific size gradient
  11775. * @param gradient defines the gradient to remove
  11776. * @returns the current particle system
  11777. */
  11778. removeSizeGradient(gradient: number): IParticleSystem;
  11779. /**
  11780. * Adds a new color remap gradient
  11781. * @param gradient defines the gradient to use (between 0 and 1)
  11782. * @param min defines the color remap minimal range
  11783. * @param max defines the color remap maximal range
  11784. * @returns the current particle system
  11785. */
  11786. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11787. /**
  11788. * Remove a specific color remap gradient
  11789. * @param gradient defines the gradient to remove
  11790. * @returns the current particle system
  11791. */
  11792. removeColorRemapGradient(gradient: number): IParticleSystem;
  11793. /**
  11794. * Adds a new alpha remap gradient
  11795. * @param gradient defines the gradient to use (between 0 and 1)
  11796. * @param min defines the alpha remap minimal range
  11797. * @param max defines the alpha remap maximal range
  11798. * @returns the current particle system
  11799. */
  11800. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11801. /**
  11802. * Remove a specific alpha remap gradient
  11803. * @param gradient defines the gradient to remove
  11804. * @returns the current particle system
  11805. */
  11806. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11807. /**
  11808. * Adds a new angular speed gradient
  11809. * @param gradient defines the gradient to use (between 0 and 1)
  11810. * @param factor defines the angular speed to affect to the specified gradient
  11811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11812. * @returns the current particle system
  11813. */
  11814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11815. /**
  11816. * Remove a specific angular speed gradient
  11817. * @param gradient defines the gradient to remove
  11818. * @returns the current particle system
  11819. */
  11820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11821. /**
  11822. * Adds a new velocity gradient
  11823. * @param gradient defines the gradient to use (between 0 and 1)
  11824. * @param factor defines the velocity to affect to the specified gradient
  11825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11826. * @returns the current particle system
  11827. */
  11828. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11829. /**
  11830. * Remove a specific velocity gradient
  11831. * @param gradient defines the gradient to remove
  11832. * @returns the current particle system
  11833. */
  11834. removeVelocityGradient(gradient: number): IParticleSystem;
  11835. /**
  11836. * Adds a new limit velocity gradient
  11837. * @param gradient defines the gradient to use (between 0 and 1)
  11838. * @param factor defines the limit velocity value to affect to the specified gradient
  11839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11840. * @returns the current particle system
  11841. */
  11842. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11843. /**
  11844. * Remove a specific limit velocity gradient
  11845. * @param gradient defines the gradient to remove
  11846. * @returns the current particle system
  11847. */
  11848. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11849. /**
  11850. * Adds a new drag gradient
  11851. * @param gradient defines the gradient to use (between 0 and 1)
  11852. * @param factor defines the drag value to affect to the specified gradient
  11853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11854. * @returns the current particle system
  11855. */
  11856. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11857. /**
  11858. * Remove a specific drag gradient
  11859. * @param gradient defines the gradient to remove
  11860. * @returns the current particle system
  11861. */
  11862. removeDragGradient(gradient: number): IParticleSystem;
  11863. /**
  11864. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11865. * @param gradient defines the gradient to use (between 0 and 1)
  11866. * @param factor defines the emit rate value to affect to the specified gradient
  11867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11868. * @returns the current particle system
  11869. */
  11870. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11871. /**
  11872. * Remove a specific emit rate gradient
  11873. * @param gradient defines the gradient to remove
  11874. * @returns the current particle system
  11875. */
  11876. removeEmitRateGradient(gradient: number): IParticleSystem;
  11877. /**
  11878. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11879. * @param gradient defines the gradient to use (between 0 and 1)
  11880. * @param factor defines the start size value to affect to the specified gradient
  11881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11882. * @returns the current particle system
  11883. */
  11884. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11885. /**
  11886. * Remove a specific start size gradient
  11887. * @param gradient defines the gradient to remove
  11888. * @returns the current particle system
  11889. */
  11890. removeStartSizeGradient(gradient: number): IParticleSystem;
  11891. private _createRampGradientTexture;
  11892. /**
  11893. * Gets the current list of ramp gradients.
  11894. * You must use addRampGradient and removeRampGradient to udpate this list
  11895. * @returns the list of ramp gradients
  11896. */
  11897. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11898. /** Force the system to rebuild all gradients that need to be resync */
  11899. forceRefreshGradients(): void;
  11900. private _syncRampGradientTexture;
  11901. /**
  11902. * Adds a new ramp gradient used to remap particle colors
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param color defines the color to affect to the specified gradient
  11905. * @returns the current particle system
  11906. */
  11907. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11908. /**
  11909. * Remove a specific ramp gradient
  11910. * @param gradient defines the gradient to remove
  11911. * @returns the current particle system
  11912. */
  11913. removeRampGradient(gradient: number): ParticleSystem;
  11914. /**
  11915. * Adds a new color gradient
  11916. * @param gradient defines the gradient to use (between 0 and 1)
  11917. * @param color1 defines the color to affect to the specified gradient
  11918. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11919. * @returns this particle system
  11920. */
  11921. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11922. /**
  11923. * Remove a specific color gradient
  11924. * @param gradient defines the gradient to remove
  11925. * @returns this particle system
  11926. */
  11927. removeColorGradient(gradient: number): IParticleSystem;
  11928. private _fetchR;
  11929. protected _reset(): void;
  11930. private _resetEffect;
  11931. private _createVertexBuffers;
  11932. private _createIndexBuffer;
  11933. /**
  11934. * Gets the maximum number of particles active at the same time.
  11935. * @returns The max number of active particles.
  11936. */
  11937. getCapacity(): number;
  11938. /**
  11939. * Gets whether there are still active particles in the system.
  11940. * @returns True if it is alive, otherwise false.
  11941. */
  11942. isAlive(): boolean;
  11943. /**
  11944. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11945. * @returns True if it has been started, otherwise false.
  11946. */
  11947. isStarted(): boolean;
  11948. private _prepareSubEmitterInternalArray;
  11949. /**
  11950. * Starts the particle system and begins to emit
  11951. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11952. */
  11953. start(delay?: number): void;
  11954. /**
  11955. * Stops the particle system.
  11956. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  11957. */
  11958. stop(stopSubEmitters?: boolean): void;
  11959. /**
  11960. * Remove all active particles
  11961. */
  11962. reset(): void;
  11963. /**
  11964. * @hidden (for internal use only)
  11965. */
  11966. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11967. /**
  11968. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11969. * Its lifetime will start back at 0.
  11970. */
  11971. recycleParticle: (particle: Particle) => void;
  11972. private _stopSubEmitters;
  11973. private _createParticle;
  11974. private _removeFromRoot;
  11975. private _emitFromParticle;
  11976. private _update;
  11977. /** @hidden */
  11978. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11979. /** @hidden */
  11980. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11981. /** @hidden */
  11982. private _getEffect;
  11983. /**
  11984. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11985. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11986. */
  11987. animate(preWarmOnly?: boolean): void;
  11988. private _appendParticleVertices;
  11989. /**
  11990. * Rebuilds the particle system.
  11991. */
  11992. rebuild(): void;
  11993. /**
  11994. * Is this system ready to be used/rendered
  11995. * @return true if the system is ready
  11996. */
  11997. isReady(): boolean;
  11998. private _render;
  11999. /**
  12000. * Renders the particle system in its current state.
  12001. * @returns the current number of particles
  12002. */
  12003. render(): number;
  12004. /**
  12005. * Disposes the particle system and free the associated resources
  12006. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12007. */
  12008. dispose(disposeTexture?: boolean): void;
  12009. /**
  12010. * Clones the particle system.
  12011. * @param name The name of the cloned object
  12012. * @param newEmitter The new emitter to use
  12013. * @returns the cloned particle system
  12014. */
  12015. clone(name: string, newEmitter: any): ParticleSystem;
  12016. /**
  12017. * Serializes the particle system to a JSON object
  12018. * @param serializeTexture defines if the texture must be serialized as well
  12019. * @returns the JSON object
  12020. */
  12021. serialize(serializeTexture?: boolean): any;
  12022. /** @hidden */
  12023. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12024. /** @hidden */
  12025. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12026. /**
  12027. * Parses a JSON object to create a particle system.
  12028. * @param parsedParticleSystem The JSON object to parse
  12029. * @param scene The scene to create the particle system in
  12030. * @param rootUrl The root url to use to load external dependencies like texture
  12031. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12032. * @returns the Parsed particle system
  12033. */
  12034. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12035. }
  12036. }
  12037. declare module BABYLON {
  12038. /**
  12039. * A particle represents one of the element emitted by a particle system.
  12040. * This is mainly define by its coordinates, direction, velocity and age.
  12041. */
  12042. export class Particle {
  12043. /**
  12044. * The particle system the particle belongs to.
  12045. */
  12046. particleSystem: ParticleSystem;
  12047. private static _Count;
  12048. /**
  12049. * Unique ID of the particle
  12050. */
  12051. id: number;
  12052. /**
  12053. * The world position of the particle in the scene.
  12054. */
  12055. position: Vector3;
  12056. /**
  12057. * The world direction of the particle in the scene.
  12058. */
  12059. direction: Vector3;
  12060. /**
  12061. * The color of the particle.
  12062. */
  12063. color: Color4;
  12064. /**
  12065. * The color change of the particle per step.
  12066. */
  12067. colorStep: Color4;
  12068. /**
  12069. * Defines how long will the life of the particle be.
  12070. */
  12071. lifeTime: number;
  12072. /**
  12073. * The current age of the particle.
  12074. */
  12075. age: number;
  12076. /**
  12077. * The current size of the particle.
  12078. */
  12079. size: number;
  12080. /**
  12081. * The current scale of the particle.
  12082. */
  12083. scale: Vector2;
  12084. /**
  12085. * The current angle of the particle.
  12086. */
  12087. angle: number;
  12088. /**
  12089. * Defines how fast is the angle changing.
  12090. */
  12091. angularSpeed: number;
  12092. /**
  12093. * Defines the cell index used by the particle to be rendered from a sprite.
  12094. */
  12095. cellIndex: number;
  12096. /**
  12097. * The information required to support color remapping
  12098. */
  12099. remapData: Vector4;
  12100. /** @hidden */
  12101. _randomCellOffset?: number;
  12102. /** @hidden */
  12103. _initialDirection: Nullable<Vector3>;
  12104. /** @hidden */
  12105. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12106. /** @hidden */
  12107. _initialStartSpriteCellID: number;
  12108. /** @hidden */
  12109. _initialEndSpriteCellID: number;
  12110. /** @hidden */
  12111. _currentColorGradient: Nullable<ColorGradient>;
  12112. /** @hidden */
  12113. _currentColor1: Color4;
  12114. /** @hidden */
  12115. _currentColor2: Color4;
  12116. /** @hidden */
  12117. _currentSizeGradient: Nullable<FactorGradient>;
  12118. /** @hidden */
  12119. _currentSize1: number;
  12120. /** @hidden */
  12121. _currentSize2: number;
  12122. /** @hidden */
  12123. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12124. /** @hidden */
  12125. _currentAngularSpeed1: number;
  12126. /** @hidden */
  12127. _currentAngularSpeed2: number;
  12128. /** @hidden */
  12129. _currentVelocityGradient: Nullable<FactorGradient>;
  12130. /** @hidden */
  12131. _currentVelocity1: number;
  12132. /** @hidden */
  12133. _currentVelocity2: number;
  12134. /** @hidden */
  12135. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12136. /** @hidden */
  12137. _currentLimitVelocity1: number;
  12138. /** @hidden */
  12139. _currentLimitVelocity2: number;
  12140. /** @hidden */
  12141. _currentDragGradient: Nullable<FactorGradient>;
  12142. /** @hidden */
  12143. _currentDrag1: number;
  12144. /** @hidden */
  12145. _currentDrag2: number;
  12146. /** @hidden */
  12147. _randomNoiseCoordinates1: Vector3;
  12148. /** @hidden */
  12149. _randomNoiseCoordinates2: Vector3;
  12150. /** @hidden */
  12151. _localPosition?: Vector3;
  12152. /**
  12153. * Creates a new instance Particle
  12154. * @param particleSystem the particle system the particle belongs to
  12155. */
  12156. constructor(
  12157. /**
  12158. * The particle system the particle belongs to.
  12159. */
  12160. particleSystem: ParticleSystem);
  12161. private updateCellInfoFromSystem;
  12162. /**
  12163. * Defines how the sprite cell index is updated for the particle
  12164. */
  12165. updateCellIndex(): void;
  12166. /** @hidden */
  12167. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12168. /** @hidden */
  12169. _inheritParticleInfoToSubEmitters(): void;
  12170. /** @hidden */
  12171. _reset(): void;
  12172. /**
  12173. * Copy the properties of particle to another one.
  12174. * @param other the particle to copy the information to.
  12175. */
  12176. copyTo(other: Particle): void;
  12177. }
  12178. }
  12179. declare module BABYLON {
  12180. /**
  12181. * Particle emitter represents a volume emitting particles.
  12182. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12183. */
  12184. export interface IParticleEmitterType {
  12185. /**
  12186. * Called by the particle System when the direction is computed for the created particle.
  12187. * @param worldMatrix is the world matrix of the particle system
  12188. * @param directionToUpdate is the direction vector to update with the result
  12189. * @param particle is the particle we are computed the direction for
  12190. * @param isLocal defines if the direction should be set in local space
  12191. */
  12192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12193. /**
  12194. * Called by the particle System when the position is computed for the created particle.
  12195. * @param worldMatrix is the world matrix of the particle system
  12196. * @param positionToUpdate is the position vector to update with the result
  12197. * @param particle is the particle we are computed the position for
  12198. * @param isLocal defines if the position should be set in local space
  12199. */
  12200. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12201. /**
  12202. * Clones the current emitter and returns a copy of it
  12203. * @returns the new emitter
  12204. */
  12205. clone(): IParticleEmitterType;
  12206. /**
  12207. * Called by the GPUParticleSystem to setup the update shader
  12208. * @param effect defines the update shader
  12209. */
  12210. applyToShader(effect: Effect): void;
  12211. /**
  12212. * Returns a string to use to update the GPU particles update shader
  12213. * @returns the effect defines string
  12214. */
  12215. getEffectDefines(): string;
  12216. /**
  12217. * Returns a string representing the class name
  12218. * @returns a string containing the class name
  12219. */
  12220. getClassName(): string;
  12221. /**
  12222. * Serializes the particle system to a JSON object.
  12223. * @returns the JSON object
  12224. */
  12225. serialize(): any;
  12226. /**
  12227. * Parse properties from a JSON object
  12228. * @param serializationObject defines the JSON object
  12229. * @param scene defines the hosting scene
  12230. */
  12231. parse(serializationObject: any, scene: Scene): void;
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * Particle emitter emitting particles from the inside of a box.
  12237. * It emits the particles randomly between 2 given directions.
  12238. */
  12239. export class BoxParticleEmitter implements IParticleEmitterType {
  12240. /**
  12241. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12242. */
  12243. direction1: Vector3;
  12244. /**
  12245. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12246. */
  12247. direction2: Vector3;
  12248. /**
  12249. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12250. */
  12251. minEmitBox: Vector3;
  12252. /**
  12253. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12254. */
  12255. maxEmitBox: Vector3;
  12256. /**
  12257. * Creates a new instance BoxParticleEmitter
  12258. */
  12259. constructor();
  12260. /**
  12261. * Called by the particle System when the direction is computed for the created particle.
  12262. * @param worldMatrix is the world matrix of the particle system
  12263. * @param directionToUpdate is the direction vector to update with the result
  12264. * @param particle is the particle we are computed the direction for
  12265. * @param isLocal defines if the direction should be set in local space
  12266. */
  12267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12268. /**
  12269. * Called by the particle System when the position is computed for the created particle.
  12270. * @param worldMatrix is the world matrix of the particle system
  12271. * @param positionToUpdate is the position vector to update with the result
  12272. * @param particle is the particle we are computed the position for
  12273. * @param isLocal defines if the position should be set in local space
  12274. */
  12275. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12276. /**
  12277. * Clones the current emitter and returns a copy of it
  12278. * @returns the new emitter
  12279. */
  12280. clone(): BoxParticleEmitter;
  12281. /**
  12282. * Called by the GPUParticleSystem to setup the update shader
  12283. * @param effect defines the update shader
  12284. */
  12285. applyToShader(effect: Effect): void;
  12286. /**
  12287. * Returns a string to use to update the GPU particles update shader
  12288. * @returns a string containng the defines string
  12289. */
  12290. getEffectDefines(): string;
  12291. /**
  12292. * Returns the string "BoxParticleEmitter"
  12293. * @returns a string containing the class name
  12294. */
  12295. getClassName(): string;
  12296. /**
  12297. * Serializes the particle system to a JSON object.
  12298. * @returns the JSON object
  12299. */
  12300. serialize(): any;
  12301. /**
  12302. * Parse properties from a JSON object
  12303. * @param serializationObject defines the JSON object
  12304. */
  12305. parse(serializationObject: any): void;
  12306. }
  12307. }
  12308. declare module BABYLON {
  12309. /**
  12310. * Particle emitter emitting particles from the inside of a cone.
  12311. * It emits the particles alongside the cone volume from the base to the particle.
  12312. * The emission direction might be randomized.
  12313. */
  12314. export class ConeParticleEmitter implements IParticleEmitterType {
  12315. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12316. directionRandomizer: number;
  12317. private _radius;
  12318. private _angle;
  12319. private _height;
  12320. /**
  12321. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12322. */
  12323. radiusRange: number;
  12324. /**
  12325. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12326. */
  12327. heightRange: number;
  12328. /**
  12329. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12330. */
  12331. emitFromSpawnPointOnly: boolean;
  12332. /**
  12333. * Gets or sets the radius of the emission cone
  12334. */
  12335. get radius(): number;
  12336. set radius(value: number);
  12337. /**
  12338. * Gets or sets the angle of the emission cone
  12339. */
  12340. get angle(): number;
  12341. set angle(value: number);
  12342. private _buildHeight;
  12343. /**
  12344. * Creates a new instance ConeParticleEmitter
  12345. * @param radius the radius of the emission cone (1 by default)
  12346. * @param angle the cone base angle (PI by default)
  12347. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12348. */
  12349. constructor(radius?: number, angle?: number,
  12350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12351. directionRandomizer?: number);
  12352. /**
  12353. * Called by the particle System when the direction is computed for the created particle.
  12354. * @param worldMatrix is the world matrix of the particle system
  12355. * @param directionToUpdate is the direction vector to update with the result
  12356. * @param particle is the particle we are computed the direction for
  12357. * @param isLocal defines if the direction should be set in local space
  12358. */
  12359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12360. /**
  12361. * Called by the particle System when the position is computed for the created particle.
  12362. * @param worldMatrix is the world matrix of the particle system
  12363. * @param positionToUpdate is the position vector to update with the result
  12364. * @param particle is the particle we are computed the position for
  12365. * @param isLocal defines if the position should be set in local space
  12366. */
  12367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12368. /**
  12369. * Clones the current emitter and returns a copy of it
  12370. * @returns the new emitter
  12371. */
  12372. clone(): ConeParticleEmitter;
  12373. /**
  12374. * Called by the GPUParticleSystem to setup the update shader
  12375. * @param effect defines the update shader
  12376. */
  12377. applyToShader(effect: Effect): void;
  12378. /**
  12379. * Returns a string to use to update the GPU particles update shader
  12380. * @returns a string containng the defines string
  12381. */
  12382. getEffectDefines(): string;
  12383. /**
  12384. * Returns the string "ConeParticleEmitter"
  12385. * @returns a string containing the class name
  12386. */
  12387. getClassName(): string;
  12388. /**
  12389. * Serializes the particle system to a JSON object.
  12390. * @returns the JSON object
  12391. */
  12392. serialize(): any;
  12393. /**
  12394. * Parse properties from a JSON object
  12395. * @param serializationObject defines the JSON object
  12396. */
  12397. parse(serializationObject: any): void;
  12398. }
  12399. }
  12400. declare module BABYLON {
  12401. /**
  12402. * Particle emitter emitting particles from the inside of a cylinder.
  12403. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12404. */
  12405. export class CylinderParticleEmitter implements IParticleEmitterType {
  12406. /**
  12407. * The radius of the emission cylinder.
  12408. */
  12409. radius: number;
  12410. /**
  12411. * The height of the emission cylinder.
  12412. */
  12413. height: number;
  12414. /**
  12415. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12416. */
  12417. radiusRange: number;
  12418. /**
  12419. * How much to randomize the particle direction [0-1].
  12420. */
  12421. directionRandomizer: number;
  12422. /**
  12423. * Creates a new instance CylinderParticleEmitter
  12424. * @param radius the radius of the emission cylinder (1 by default)
  12425. * @param height the height of the emission cylinder (1 by default)
  12426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12427. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12428. */
  12429. constructor(
  12430. /**
  12431. * The radius of the emission cylinder.
  12432. */
  12433. radius?: number,
  12434. /**
  12435. * The height of the emission cylinder.
  12436. */
  12437. height?: number,
  12438. /**
  12439. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12440. */
  12441. radiusRange?: number,
  12442. /**
  12443. * How much to randomize the particle direction [0-1].
  12444. */
  12445. directionRandomizer?: number);
  12446. /**
  12447. * Called by the particle System when the direction is computed for the created particle.
  12448. * @param worldMatrix is the world matrix of the particle system
  12449. * @param directionToUpdate is the direction vector to update with the result
  12450. * @param particle is the particle we are computed the direction for
  12451. * @param isLocal defines if the direction should be set in local space
  12452. */
  12453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12454. /**
  12455. * Called by the particle System when the position is computed for the created particle.
  12456. * @param worldMatrix is the world matrix of the particle system
  12457. * @param positionToUpdate is the position vector to update with the result
  12458. * @param particle is the particle we are computed the position for
  12459. * @param isLocal defines if the position should be set in local space
  12460. */
  12461. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12462. /**
  12463. * Clones the current emitter and returns a copy of it
  12464. * @returns the new emitter
  12465. */
  12466. clone(): CylinderParticleEmitter;
  12467. /**
  12468. * Called by the GPUParticleSystem to setup the update shader
  12469. * @param effect defines the update shader
  12470. */
  12471. applyToShader(effect: Effect): void;
  12472. /**
  12473. * Returns a string to use to update the GPU particles update shader
  12474. * @returns a string containng the defines string
  12475. */
  12476. getEffectDefines(): string;
  12477. /**
  12478. * Returns the string "CylinderParticleEmitter"
  12479. * @returns a string containing the class name
  12480. */
  12481. getClassName(): string;
  12482. /**
  12483. * Serializes the particle system to a JSON object.
  12484. * @returns the JSON object
  12485. */
  12486. serialize(): any;
  12487. /**
  12488. * Parse properties from a JSON object
  12489. * @param serializationObject defines the JSON object
  12490. */
  12491. parse(serializationObject: any): void;
  12492. }
  12493. /**
  12494. * Particle emitter emitting particles from the inside of a cylinder.
  12495. * It emits the particles randomly between two vectors.
  12496. */
  12497. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12498. /**
  12499. * The min limit of the emission direction.
  12500. */
  12501. direction1: Vector3;
  12502. /**
  12503. * The max limit of the emission direction.
  12504. */
  12505. direction2: Vector3;
  12506. /**
  12507. * Creates a new instance CylinderDirectedParticleEmitter
  12508. * @param radius the radius of the emission cylinder (1 by default)
  12509. * @param height the height of the emission cylinder (1 by default)
  12510. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12511. * @param direction1 the min limit of the emission direction (up vector by default)
  12512. * @param direction2 the max limit of the emission direction (up vector by default)
  12513. */
  12514. constructor(radius?: number, height?: number, radiusRange?: number,
  12515. /**
  12516. * The min limit of the emission direction.
  12517. */
  12518. direction1?: Vector3,
  12519. /**
  12520. * The max limit of the emission direction.
  12521. */
  12522. direction2?: Vector3);
  12523. /**
  12524. * Called by the particle System when the direction is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param directionToUpdate is the direction vector to update with the result
  12527. * @param particle is the particle we are computed the direction for
  12528. */
  12529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12530. /**
  12531. * Clones the current emitter and returns a copy of it
  12532. * @returns the new emitter
  12533. */
  12534. clone(): CylinderDirectedParticleEmitter;
  12535. /**
  12536. * Called by the GPUParticleSystem to setup the update shader
  12537. * @param effect defines the update shader
  12538. */
  12539. applyToShader(effect: Effect): void;
  12540. /**
  12541. * Returns a string to use to update the GPU particles update shader
  12542. * @returns a string containng the defines string
  12543. */
  12544. getEffectDefines(): string;
  12545. /**
  12546. * Returns the string "CylinderDirectedParticleEmitter"
  12547. * @returns a string containing the class name
  12548. */
  12549. getClassName(): string;
  12550. /**
  12551. * Serializes the particle system to a JSON object.
  12552. * @returns the JSON object
  12553. */
  12554. serialize(): any;
  12555. /**
  12556. * Parse properties from a JSON object
  12557. * @param serializationObject defines the JSON object
  12558. */
  12559. parse(serializationObject: any): void;
  12560. }
  12561. }
  12562. declare module BABYLON {
  12563. /**
  12564. * Particle emitter emitting particles from the inside of a hemisphere.
  12565. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12566. */
  12567. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12568. /**
  12569. * The radius of the emission hemisphere.
  12570. */
  12571. radius: number;
  12572. /**
  12573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12574. */
  12575. radiusRange: number;
  12576. /**
  12577. * How much to randomize the particle direction [0-1].
  12578. */
  12579. directionRandomizer: number;
  12580. /**
  12581. * Creates a new instance HemisphericParticleEmitter
  12582. * @param radius the radius of the emission hemisphere (1 by default)
  12583. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12584. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12585. */
  12586. constructor(
  12587. /**
  12588. * The radius of the emission hemisphere.
  12589. */
  12590. radius?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. * @param isLocal defines if the direction should be set in local space
  12605. */
  12606. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12607. /**
  12608. * Called by the particle System when the position is computed for the created particle.
  12609. * @param worldMatrix is the world matrix of the particle system
  12610. * @param positionToUpdate is the position vector to update with the result
  12611. * @param particle is the particle we are computed the position for
  12612. * @param isLocal defines if the position should be set in local space
  12613. */
  12614. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12615. /**
  12616. * Clones the current emitter and returns a copy of it
  12617. * @returns the new emitter
  12618. */
  12619. clone(): HemisphericParticleEmitter;
  12620. /**
  12621. * Called by the GPUParticleSystem to setup the update shader
  12622. * @param effect defines the update shader
  12623. */
  12624. applyToShader(effect: Effect): void;
  12625. /**
  12626. * Returns a string to use to update the GPU particles update shader
  12627. * @returns a string containng the defines string
  12628. */
  12629. getEffectDefines(): string;
  12630. /**
  12631. * Returns the string "HemisphericParticleEmitter"
  12632. * @returns a string containing the class name
  12633. */
  12634. getClassName(): string;
  12635. /**
  12636. * Serializes the particle system to a JSON object.
  12637. * @returns the JSON object
  12638. */
  12639. serialize(): any;
  12640. /**
  12641. * Parse properties from a JSON object
  12642. * @param serializationObject defines the JSON object
  12643. */
  12644. parse(serializationObject: any): void;
  12645. }
  12646. }
  12647. declare module BABYLON {
  12648. /**
  12649. * Particle emitter emitting particles from a point.
  12650. * It emits the particles randomly between 2 given directions.
  12651. */
  12652. export class PointParticleEmitter implements IParticleEmitterType {
  12653. /**
  12654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12655. */
  12656. direction1: Vector3;
  12657. /**
  12658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12659. */
  12660. direction2: Vector3;
  12661. /**
  12662. * Creates a new instance PointParticleEmitter
  12663. */
  12664. constructor();
  12665. /**
  12666. * Called by the particle System when the direction is computed for the created particle.
  12667. * @param worldMatrix is the world matrix of the particle system
  12668. * @param directionToUpdate is the direction vector to update with the result
  12669. * @param particle is the particle we are computed the direction for
  12670. * @param isLocal defines if the direction should be set in local space
  12671. */
  12672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12673. /**
  12674. * Called by the particle System when the position is computed for the created particle.
  12675. * @param worldMatrix is the world matrix of the particle system
  12676. * @param positionToUpdate is the position vector to update with the result
  12677. * @param particle is the particle we are computed the position for
  12678. * @param isLocal defines if the position should be set in local space
  12679. */
  12680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): PointParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "PointParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module BABYLON {
  12714. /**
  12715. * Particle emitter emitting particles from the inside of a sphere.
  12716. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12717. */
  12718. export class SphereParticleEmitter implements IParticleEmitterType {
  12719. /**
  12720. * The radius of the emission sphere.
  12721. */
  12722. radius: number;
  12723. /**
  12724. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12725. */
  12726. radiusRange: number;
  12727. /**
  12728. * How much to randomize the particle direction [0-1].
  12729. */
  12730. directionRandomizer: number;
  12731. /**
  12732. * Creates a new instance SphereParticleEmitter
  12733. * @param radius the radius of the emission sphere (1 by default)
  12734. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12735. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12736. */
  12737. constructor(
  12738. /**
  12739. * The radius of the emission sphere.
  12740. */
  12741. radius?: number,
  12742. /**
  12743. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12744. */
  12745. radiusRange?: number,
  12746. /**
  12747. * How much to randomize the particle direction [0-1].
  12748. */
  12749. directionRandomizer?: number);
  12750. /**
  12751. * Called by the particle System when the direction is computed for the created particle.
  12752. * @param worldMatrix is the world matrix of the particle system
  12753. * @param directionToUpdate is the direction vector to update with the result
  12754. * @param particle is the particle we are computed the direction for
  12755. * @param isLocal defines if the direction should be set in local space
  12756. */
  12757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12758. /**
  12759. * Called by the particle System when the position is computed for the created particle.
  12760. * @param worldMatrix is the world matrix of the particle system
  12761. * @param positionToUpdate is the position vector to update with the result
  12762. * @param particle is the particle we are computed the position for
  12763. * @param isLocal defines if the position should be set in local space
  12764. */
  12765. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12766. /**
  12767. * Clones the current emitter and returns a copy of it
  12768. * @returns the new emitter
  12769. */
  12770. clone(): SphereParticleEmitter;
  12771. /**
  12772. * Called by the GPUParticleSystem to setup the update shader
  12773. * @param effect defines the update shader
  12774. */
  12775. applyToShader(effect: Effect): void;
  12776. /**
  12777. * Returns a string to use to update the GPU particles update shader
  12778. * @returns a string containng the defines string
  12779. */
  12780. getEffectDefines(): string;
  12781. /**
  12782. * Returns the string "SphereParticleEmitter"
  12783. * @returns a string containing the class name
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Serializes the particle system to a JSON object.
  12788. * @returns the JSON object
  12789. */
  12790. serialize(): any;
  12791. /**
  12792. * Parse properties from a JSON object
  12793. * @param serializationObject defines the JSON object
  12794. */
  12795. parse(serializationObject: any): void;
  12796. }
  12797. /**
  12798. * Particle emitter emitting particles from the inside of a sphere.
  12799. * It emits the particles randomly between two vectors.
  12800. */
  12801. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12802. /**
  12803. * The min limit of the emission direction.
  12804. */
  12805. direction1: Vector3;
  12806. /**
  12807. * The max limit of the emission direction.
  12808. */
  12809. direction2: Vector3;
  12810. /**
  12811. * Creates a new instance SphereDirectedParticleEmitter
  12812. * @param radius the radius of the emission sphere (1 by default)
  12813. * @param direction1 the min limit of the emission direction (up vector by default)
  12814. * @param direction2 the max limit of the emission direction (up vector by default)
  12815. */
  12816. constructor(radius?: number,
  12817. /**
  12818. * The min limit of the emission direction.
  12819. */
  12820. direction1?: Vector3,
  12821. /**
  12822. * The max limit of the emission direction.
  12823. */
  12824. direction2?: Vector3);
  12825. /**
  12826. * Called by the particle System when the direction is computed for the created particle.
  12827. * @param worldMatrix is the world matrix of the particle system
  12828. * @param directionToUpdate is the direction vector to update with the result
  12829. * @param particle is the particle we are computed the direction for
  12830. */
  12831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12832. /**
  12833. * Clones the current emitter and returns a copy of it
  12834. * @returns the new emitter
  12835. */
  12836. clone(): SphereDirectedParticleEmitter;
  12837. /**
  12838. * Called by the GPUParticleSystem to setup the update shader
  12839. * @param effect defines the update shader
  12840. */
  12841. applyToShader(effect: Effect): void;
  12842. /**
  12843. * Returns a string to use to update the GPU particles update shader
  12844. * @returns a string containng the defines string
  12845. */
  12846. getEffectDefines(): string;
  12847. /**
  12848. * Returns the string "SphereDirectedParticleEmitter"
  12849. * @returns a string containing the class name
  12850. */
  12851. getClassName(): string;
  12852. /**
  12853. * Serializes the particle system to a JSON object.
  12854. * @returns the JSON object
  12855. */
  12856. serialize(): any;
  12857. /**
  12858. * Parse properties from a JSON object
  12859. * @param serializationObject defines the JSON object
  12860. */
  12861. parse(serializationObject: any): void;
  12862. }
  12863. }
  12864. declare module BABYLON {
  12865. /**
  12866. * Particle emitter emitting particles from a custom list of positions.
  12867. */
  12868. export class CustomParticleEmitter implements IParticleEmitterType {
  12869. /**
  12870. * Gets or sets the position generator that will create the inital position of each particle.
  12871. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12872. */
  12873. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12874. /**
  12875. * Gets or sets the destination generator that will create the final destination of each particle.
  12876. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12877. */
  12878. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12879. /**
  12880. * Creates a new instance CustomParticleEmitter
  12881. */
  12882. constructor();
  12883. /**
  12884. * Called by the particle System when the direction is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param directionToUpdate is the direction vector to update with the result
  12887. * @param particle is the particle we are computed the direction for
  12888. * @param isLocal defines if the direction should be set in local space
  12889. */
  12890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Called by the particle System when the position is computed for the created particle.
  12893. * @param worldMatrix is the world matrix of the particle system
  12894. * @param positionToUpdate is the position vector to update with the result
  12895. * @param particle is the particle we are computed the position for
  12896. * @param isLocal defines if the position should be set in local space
  12897. */
  12898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12899. /**
  12900. * Clones the current emitter and returns a copy of it
  12901. * @returns the new emitter
  12902. */
  12903. clone(): CustomParticleEmitter;
  12904. /**
  12905. * Called by the GPUParticleSystem to setup the update shader
  12906. * @param effect defines the update shader
  12907. */
  12908. applyToShader(effect: Effect): void;
  12909. /**
  12910. * Returns a string to use to update the GPU particles update shader
  12911. * @returns a string containng the defines string
  12912. */
  12913. getEffectDefines(): string;
  12914. /**
  12915. * Returns the string "PointParticleEmitter"
  12916. * @returns a string containing the class name
  12917. */
  12918. getClassName(): string;
  12919. /**
  12920. * Serializes the particle system to a JSON object.
  12921. * @returns the JSON object
  12922. */
  12923. serialize(): any;
  12924. /**
  12925. * Parse properties from a JSON object
  12926. * @param serializationObject defines the JSON object
  12927. */
  12928. parse(serializationObject: any): void;
  12929. }
  12930. }
  12931. declare module BABYLON {
  12932. /**
  12933. * Particle emitter emitting particles from the inside of a box.
  12934. * It emits the particles randomly between 2 given directions.
  12935. */
  12936. export class MeshParticleEmitter implements IParticleEmitterType {
  12937. private _indices;
  12938. private _positions;
  12939. private _normals;
  12940. private _storedNormal;
  12941. private _mesh;
  12942. /**
  12943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12944. */
  12945. direction1: Vector3;
  12946. /**
  12947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12948. */
  12949. direction2: Vector3;
  12950. /**
  12951. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12952. */
  12953. useMeshNormalsForDirection: boolean;
  12954. /** Defines the mesh to use as source */
  12955. get mesh(): Nullable<AbstractMesh>;
  12956. set mesh(value: Nullable<AbstractMesh>);
  12957. /**
  12958. * Creates a new instance MeshParticleEmitter
  12959. * @param mesh defines the mesh to use as source
  12960. */
  12961. constructor(mesh?: Nullable<AbstractMesh>);
  12962. /**
  12963. * Called by the particle System when the direction is computed for the created particle.
  12964. * @param worldMatrix is the world matrix of the particle system
  12965. * @param directionToUpdate is the direction vector to update with the result
  12966. * @param particle is the particle we are computed the direction for
  12967. * @param isLocal defines if the direction should be set in local space
  12968. */
  12969. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12970. /**
  12971. * Called by the particle System when the position is computed for the created particle.
  12972. * @param worldMatrix is the world matrix of the particle system
  12973. * @param positionToUpdate is the position vector to update with the result
  12974. * @param particle is the particle we are computed the position for
  12975. * @param isLocal defines if the position should be set in local space
  12976. */
  12977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12978. /**
  12979. * Clones the current emitter and returns a copy of it
  12980. * @returns the new emitter
  12981. */
  12982. clone(): MeshParticleEmitter;
  12983. /**
  12984. * Called by the GPUParticleSystem to setup the update shader
  12985. * @param effect defines the update shader
  12986. */
  12987. applyToShader(effect: Effect): void;
  12988. /**
  12989. * Returns a string to use to update the GPU particles update shader
  12990. * @returns a string containng the defines string
  12991. */
  12992. getEffectDefines(): string;
  12993. /**
  12994. * Returns the string "BoxParticleEmitter"
  12995. * @returns a string containing the class name
  12996. */
  12997. getClassName(): string;
  12998. /**
  12999. * Serializes the particle system to a JSON object.
  13000. * @returns the JSON object
  13001. */
  13002. serialize(): any;
  13003. /**
  13004. * Parse properties from a JSON object
  13005. * @param serializationObject defines the JSON object
  13006. * @param scene defines the hosting scene
  13007. */
  13008. parse(serializationObject: any, scene: Scene): void;
  13009. }
  13010. }
  13011. declare module BABYLON {
  13012. /**
  13013. * Interface representing a particle system in Babylon.js.
  13014. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13015. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13016. */
  13017. export interface IParticleSystem {
  13018. /**
  13019. * List of animations used by the particle system.
  13020. */
  13021. animations: Animation[];
  13022. /**
  13023. * The id of the Particle system.
  13024. */
  13025. id: string;
  13026. /**
  13027. * The name of the Particle system.
  13028. */
  13029. name: string;
  13030. /**
  13031. * The emitter represents the Mesh or position we are attaching the particle system to.
  13032. */
  13033. emitter: Nullable<AbstractMesh | Vector3>;
  13034. /**
  13035. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13036. */
  13037. isBillboardBased: boolean;
  13038. /**
  13039. * The rendering group used by the Particle system to chose when to render.
  13040. */
  13041. renderingGroupId: number;
  13042. /**
  13043. * The layer mask we are rendering the particles through.
  13044. */
  13045. layerMask: number;
  13046. /**
  13047. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13048. */
  13049. updateSpeed: number;
  13050. /**
  13051. * The amount of time the particle system is running (depends of the overall update speed).
  13052. */
  13053. targetStopDuration: number;
  13054. /**
  13055. * The texture used to render each particle. (this can be a spritesheet)
  13056. */
  13057. particleTexture: Nullable<Texture>;
  13058. /**
  13059. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13060. */
  13061. blendMode: number;
  13062. /**
  13063. * Minimum life time of emitting particles.
  13064. */
  13065. minLifeTime: number;
  13066. /**
  13067. * Maximum life time of emitting particles.
  13068. */
  13069. maxLifeTime: number;
  13070. /**
  13071. * Minimum Size of emitting particles.
  13072. */
  13073. minSize: number;
  13074. /**
  13075. * Maximum Size of emitting particles.
  13076. */
  13077. maxSize: number;
  13078. /**
  13079. * Minimum scale of emitting particles on X axis.
  13080. */
  13081. minScaleX: number;
  13082. /**
  13083. * Maximum scale of emitting particles on X axis.
  13084. */
  13085. maxScaleX: number;
  13086. /**
  13087. * Minimum scale of emitting particles on Y axis.
  13088. */
  13089. minScaleY: number;
  13090. /**
  13091. * Maximum scale of emitting particles on Y axis.
  13092. */
  13093. maxScaleY: number;
  13094. /**
  13095. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13096. */
  13097. color1: Color4;
  13098. /**
  13099. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13100. */
  13101. color2: Color4;
  13102. /**
  13103. * Color the particle will have at the end of its lifetime.
  13104. */
  13105. colorDead: Color4;
  13106. /**
  13107. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13108. */
  13109. emitRate: number;
  13110. /**
  13111. * You can use gravity if you want to give an orientation to your particles.
  13112. */
  13113. gravity: Vector3;
  13114. /**
  13115. * Minimum power of emitting particles.
  13116. */
  13117. minEmitPower: number;
  13118. /**
  13119. * Maximum power of emitting particles.
  13120. */
  13121. maxEmitPower: number;
  13122. /**
  13123. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13124. */
  13125. minAngularSpeed: number;
  13126. /**
  13127. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13128. */
  13129. maxAngularSpeed: number;
  13130. /**
  13131. * Gets or sets the minimal initial rotation in radians.
  13132. */
  13133. minInitialRotation: number;
  13134. /**
  13135. * Gets or sets the maximal initial rotation in radians.
  13136. */
  13137. maxInitialRotation: number;
  13138. /**
  13139. * The particle emitter type defines the emitter used by the particle system.
  13140. * It can be for example box, sphere, or cone...
  13141. */
  13142. particleEmitterType: Nullable<IParticleEmitterType>;
  13143. /**
  13144. * Defines the delay in milliseconds before starting the system (0 by default)
  13145. */
  13146. startDelay: number;
  13147. /**
  13148. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13149. */
  13150. preWarmCycles: number;
  13151. /**
  13152. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13153. */
  13154. preWarmStepOffset: number;
  13155. /**
  13156. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13157. */
  13158. spriteCellChangeSpeed: number;
  13159. /**
  13160. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13161. */
  13162. startSpriteCellID: number;
  13163. /**
  13164. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13165. */
  13166. endSpriteCellID: number;
  13167. /**
  13168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13169. */
  13170. spriteCellWidth: number;
  13171. /**
  13172. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13173. */
  13174. spriteCellHeight: number;
  13175. /**
  13176. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13177. */
  13178. spriteRandomStartCell: boolean;
  13179. /**
  13180. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13181. */
  13182. isAnimationSheetEnabled: boolean;
  13183. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13184. translationPivot: Vector2;
  13185. /**
  13186. * Gets or sets a texture used to add random noise to particle positions
  13187. */
  13188. noiseTexture: Nullable<BaseTexture>;
  13189. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13190. noiseStrength: Vector3;
  13191. /**
  13192. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13193. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13194. */
  13195. billboardMode: number;
  13196. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13197. limitVelocityDamping: number;
  13198. /**
  13199. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13200. */
  13201. beginAnimationOnStart: boolean;
  13202. /**
  13203. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13204. */
  13205. beginAnimationFrom: number;
  13206. /**
  13207. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13208. */
  13209. beginAnimationTo: number;
  13210. /**
  13211. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13212. */
  13213. beginAnimationLoop: boolean;
  13214. /**
  13215. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13216. */
  13217. disposeOnStop: boolean;
  13218. /**
  13219. * Specifies if the particles are updated in emitter local space or world space
  13220. */
  13221. isLocal: boolean;
  13222. /** Snippet ID if the particle system was created from the snippet server */
  13223. snippetId: string;
  13224. /**
  13225. * Gets the maximum number of particles active at the same time.
  13226. * @returns The max number of active particles.
  13227. */
  13228. getCapacity(): number;
  13229. /**
  13230. * Gets the number of particles active at the same time.
  13231. * @returns The number of active particles.
  13232. */
  13233. getActiveCount(): number;
  13234. /**
  13235. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13236. * @returns True if it has been started, otherwise false.
  13237. */
  13238. isStarted(): boolean;
  13239. /**
  13240. * Animates the particle system for this frame.
  13241. */
  13242. animate(): void;
  13243. /**
  13244. * Renders the particle system in its current state.
  13245. * @returns the current number of particles
  13246. */
  13247. render(): number;
  13248. /**
  13249. * Dispose the particle system and frees its associated resources.
  13250. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13251. */
  13252. dispose(disposeTexture?: boolean): void;
  13253. /**
  13254. * Clones the particle system.
  13255. * @param name The name of the cloned object
  13256. * @param newEmitter The new emitter to use
  13257. * @returns the cloned particle system
  13258. */
  13259. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13260. /**
  13261. * Serializes the particle system to a JSON object
  13262. * @param serializeTexture defines if the texture must be serialized as well
  13263. * @returns the JSON object
  13264. */
  13265. serialize(serializeTexture: boolean): any;
  13266. /**
  13267. * Rebuild the particle system
  13268. */
  13269. rebuild(): void;
  13270. /** Force the system to rebuild all gradients that need to be resync */
  13271. forceRefreshGradients(): void;
  13272. /**
  13273. * Starts the particle system and begins to emit
  13274. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13275. */
  13276. start(delay?: number): void;
  13277. /**
  13278. * Stops the particle system.
  13279. */
  13280. stop(): void;
  13281. /**
  13282. * Remove all active particles
  13283. */
  13284. reset(): void;
  13285. /**
  13286. * Gets a boolean indicating that the system is stopping
  13287. * @returns true if the system is currently stopping
  13288. */
  13289. isStopping(): boolean;
  13290. /**
  13291. * Is this system ready to be used/rendered
  13292. * @return true if the system is ready
  13293. */
  13294. isReady(): boolean;
  13295. /**
  13296. * Returns the string "ParticleSystem"
  13297. * @returns a string containing the class name
  13298. */
  13299. getClassName(): string;
  13300. /**
  13301. * Adds a new color gradient
  13302. * @param gradient defines the gradient to use (between 0 and 1)
  13303. * @param color1 defines the color to affect to the specified gradient
  13304. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13305. * @returns the current particle system
  13306. */
  13307. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13308. /**
  13309. * Remove a specific color gradient
  13310. * @param gradient defines the gradient to remove
  13311. * @returns the current particle system
  13312. */
  13313. removeColorGradient(gradient: number): IParticleSystem;
  13314. /**
  13315. * Adds a new size gradient
  13316. * @param gradient defines the gradient to use (between 0 and 1)
  13317. * @param factor defines the size factor to affect to the specified gradient
  13318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13319. * @returns the current particle system
  13320. */
  13321. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13322. /**
  13323. * Remove a specific size gradient
  13324. * @param gradient defines the gradient to remove
  13325. * @returns the current particle system
  13326. */
  13327. removeSizeGradient(gradient: number): IParticleSystem;
  13328. /**
  13329. * Gets the current list of color gradients.
  13330. * You must use addColorGradient and removeColorGradient to udpate this list
  13331. * @returns the list of color gradients
  13332. */
  13333. getColorGradients(): Nullable<Array<ColorGradient>>;
  13334. /**
  13335. * Gets the current list of size gradients.
  13336. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13337. * @returns the list of size gradients
  13338. */
  13339. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13340. /**
  13341. * Gets the current list of angular speed gradients.
  13342. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13343. * @returns the list of angular speed gradients
  13344. */
  13345. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13346. /**
  13347. * Adds a new angular speed gradient
  13348. * @param gradient defines the gradient to use (between 0 and 1)
  13349. * @param factor defines the angular speed to affect to the specified gradient
  13350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13351. * @returns the current particle system
  13352. */
  13353. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13354. /**
  13355. * Remove a specific angular speed gradient
  13356. * @param gradient defines the gradient to remove
  13357. * @returns the current particle system
  13358. */
  13359. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13360. /**
  13361. * Gets the current list of velocity gradients.
  13362. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13363. * @returns the list of velocity gradients
  13364. */
  13365. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13366. /**
  13367. * Adds a new velocity gradient
  13368. * @param gradient defines the gradient to use (between 0 and 1)
  13369. * @param factor defines the velocity to affect to the specified gradient
  13370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13371. * @returns the current particle system
  13372. */
  13373. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13374. /**
  13375. * Remove a specific velocity gradient
  13376. * @param gradient defines the gradient to remove
  13377. * @returns the current particle system
  13378. */
  13379. removeVelocityGradient(gradient: number): IParticleSystem;
  13380. /**
  13381. * Gets the current list of limit velocity gradients.
  13382. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13383. * @returns the list of limit velocity gradients
  13384. */
  13385. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13386. /**
  13387. * Adds a new limit velocity gradient
  13388. * @param gradient defines the gradient to use (between 0 and 1)
  13389. * @param factor defines the limit velocity to affect to the specified gradient
  13390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13391. * @returns the current particle system
  13392. */
  13393. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13394. /**
  13395. * Remove a specific limit velocity gradient
  13396. * @param gradient defines the gradient to remove
  13397. * @returns the current particle system
  13398. */
  13399. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13400. /**
  13401. * Adds a new drag gradient
  13402. * @param gradient defines the gradient to use (between 0 and 1)
  13403. * @param factor defines the drag to affect to the specified gradient
  13404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13405. * @returns the current particle system
  13406. */
  13407. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13408. /**
  13409. * Remove a specific drag gradient
  13410. * @param gradient defines the gradient to remove
  13411. * @returns the current particle system
  13412. */
  13413. removeDragGradient(gradient: number): IParticleSystem;
  13414. /**
  13415. * Gets the current list of drag gradients.
  13416. * You must use addDragGradient and removeDragGradient to udpate this list
  13417. * @returns the list of drag gradients
  13418. */
  13419. getDragGradients(): Nullable<Array<FactorGradient>>;
  13420. /**
  13421. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13422. * @param gradient defines the gradient to use (between 0 and 1)
  13423. * @param factor defines the emit rate to affect to the specified gradient
  13424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13425. * @returns the current particle system
  13426. */
  13427. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13428. /**
  13429. * Remove a specific emit rate gradient
  13430. * @param gradient defines the gradient to remove
  13431. * @returns the current particle system
  13432. */
  13433. removeEmitRateGradient(gradient: number): IParticleSystem;
  13434. /**
  13435. * Gets the current list of emit rate gradients.
  13436. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13437. * @returns the list of emit rate gradients
  13438. */
  13439. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13440. /**
  13441. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13442. * @param gradient defines the gradient to use (between 0 and 1)
  13443. * @param factor defines the start size to affect to the specified gradient
  13444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13445. * @returns the current particle system
  13446. */
  13447. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13448. /**
  13449. * Remove a specific start size gradient
  13450. * @param gradient defines the gradient to remove
  13451. * @returns the current particle system
  13452. */
  13453. removeStartSizeGradient(gradient: number): IParticleSystem;
  13454. /**
  13455. * Gets the current list of start size gradients.
  13456. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13457. * @returns the list of start size gradients
  13458. */
  13459. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13460. /**
  13461. * Adds a new life time gradient
  13462. * @param gradient defines the gradient to use (between 0 and 1)
  13463. * @param factor defines the life time factor to affect to the specified gradient
  13464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13465. * @returns the current particle system
  13466. */
  13467. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13468. /**
  13469. * Remove a specific life time gradient
  13470. * @param gradient defines the gradient to remove
  13471. * @returns the current particle system
  13472. */
  13473. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13474. /**
  13475. * Gets the current list of life time gradients.
  13476. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13477. * @returns the list of life time gradients
  13478. */
  13479. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13480. /**
  13481. * Gets the current list of color gradients.
  13482. * You must use addColorGradient and removeColorGradient to udpate this list
  13483. * @returns the list of color gradients
  13484. */
  13485. getColorGradients(): Nullable<Array<ColorGradient>>;
  13486. /**
  13487. * Adds a new ramp gradient used to remap particle colors
  13488. * @param gradient defines the gradient to use (between 0 and 1)
  13489. * @param color defines the color to affect to the specified gradient
  13490. * @returns the current particle system
  13491. */
  13492. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13493. /**
  13494. * Gets the current list of ramp gradients.
  13495. * You must use addRampGradient and removeRampGradient to udpate this list
  13496. * @returns the list of ramp gradients
  13497. */
  13498. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13499. /** Gets or sets a boolean indicating that ramp gradients must be used
  13500. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13501. */
  13502. useRampGradients: boolean;
  13503. /**
  13504. * Adds a new color remap gradient
  13505. * @param gradient defines the gradient to use (between 0 and 1)
  13506. * @param min defines the color remap minimal range
  13507. * @param max defines the color remap maximal range
  13508. * @returns the current particle system
  13509. */
  13510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13511. /**
  13512. * Gets the current list of color remap gradients.
  13513. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13514. * @returns the list of color remap gradients
  13515. */
  13516. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13517. /**
  13518. * Adds a new alpha remap gradient
  13519. * @param gradient defines the gradient to use (between 0 and 1)
  13520. * @param min defines the alpha remap minimal range
  13521. * @param max defines the alpha remap maximal range
  13522. * @returns the current particle system
  13523. */
  13524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13525. /**
  13526. * Gets the current list of alpha remap gradients.
  13527. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13528. * @returns the list of alpha remap gradients
  13529. */
  13530. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13531. /**
  13532. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13535. * @returns the emitter
  13536. */
  13537. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13538. /**
  13539. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13540. * @param radius The radius of the hemisphere to emit from
  13541. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13542. * @returns the emitter
  13543. */
  13544. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13545. /**
  13546. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13547. * @param radius The radius of the sphere to emit from
  13548. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13549. * @returns the emitter
  13550. */
  13551. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13552. /**
  13553. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13554. * @param radius The radius of the sphere to emit from
  13555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13557. * @returns the emitter
  13558. */
  13559. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13560. /**
  13561. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13562. * @param radius The radius of the emission cylinder
  13563. * @param height The height of the emission cylinder
  13564. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13565. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13566. * @returns the emitter
  13567. */
  13568. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13569. /**
  13570. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13571. * @param radius The radius of the cylinder to emit from
  13572. * @param height The height of the emission cylinder
  13573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13576. * @returns the emitter
  13577. */
  13578. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13579. /**
  13580. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13581. * @param radius The radius of the cone to emit from
  13582. * @param angle The base angle of the cone
  13583. * @returns the emitter
  13584. */
  13585. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13586. /**
  13587. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13590. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13591. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13592. * @returns the emitter
  13593. */
  13594. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13595. /**
  13596. * Get hosting scene
  13597. * @returns the scene
  13598. */
  13599. getScene(): Scene;
  13600. }
  13601. }
  13602. declare module BABYLON {
  13603. /**
  13604. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13605. * @see https://doc.babylonjs.com/how_to/transformnode
  13606. */
  13607. export class TransformNode extends Node {
  13608. /**
  13609. * Object will not rotate to face the camera
  13610. */
  13611. static BILLBOARDMODE_NONE: number;
  13612. /**
  13613. * Object will rotate to face the camera but only on the x axis
  13614. */
  13615. static BILLBOARDMODE_X: number;
  13616. /**
  13617. * Object will rotate to face the camera but only on the y axis
  13618. */
  13619. static BILLBOARDMODE_Y: number;
  13620. /**
  13621. * Object will rotate to face the camera but only on the z axis
  13622. */
  13623. static BILLBOARDMODE_Z: number;
  13624. /**
  13625. * Object will rotate to face the camera
  13626. */
  13627. static BILLBOARDMODE_ALL: number;
  13628. /**
  13629. * Object will rotate to face the camera's position instead of orientation
  13630. */
  13631. static BILLBOARDMODE_USE_POSITION: number;
  13632. private _forward;
  13633. private _forwardInverted;
  13634. private _up;
  13635. private _right;
  13636. private _rightInverted;
  13637. private _position;
  13638. private _rotation;
  13639. private _rotationQuaternion;
  13640. protected _scaling: Vector3;
  13641. protected _isDirty: boolean;
  13642. private _transformToBoneReferal;
  13643. private _isAbsoluteSynced;
  13644. private _billboardMode;
  13645. /**
  13646. * Gets or sets the billboard mode. Default is 0.
  13647. *
  13648. * | Value | Type | Description |
  13649. * | --- | --- | --- |
  13650. * | 0 | BILLBOARDMODE_NONE | |
  13651. * | 1 | BILLBOARDMODE_X | |
  13652. * | 2 | BILLBOARDMODE_Y | |
  13653. * | 4 | BILLBOARDMODE_Z | |
  13654. * | 7 | BILLBOARDMODE_ALL | |
  13655. *
  13656. */
  13657. get billboardMode(): number;
  13658. set billboardMode(value: number);
  13659. private _preserveParentRotationForBillboard;
  13660. /**
  13661. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13662. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13663. */
  13664. get preserveParentRotationForBillboard(): boolean;
  13665. set preserveParentRotationForBillboard(value: boolean);
  13666. /**
  13667. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13668. */
  13669. scalingDeterminant: number;
  13670. private _infiniteDistance;
  13671. /**
  13672. * Gets or sets the distance of the object to max, often used by skybox
  13673. */
  13674. get infiniteDistance(): boolean;
  13675. set infiniteDistance(value: boolean);
  13676. /**
  13677. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13678. * By default the system will update normals to compensate
  13679. */
  13680. ignoreNonUniformScaling: boolean;
  13681. /**
  13682. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13683. */
  13684. reIntegrateRotationIntoRotationQuaternion: boolean;
  13685. /** @hidden */
  13686. _poseMatrix: Nullable<Matrix>;
  13687. /** @hidden */
  13688. _localMatrix: Matrix;
  13689. private _usePivotMatrix;
  13690. private _absolutePosition;
  13691. private _absoluteScaling;
  13692. private _absoluteRotationQuaternion;
  13693. private _pivotMatrix;
  13694. private _pivotMatrixInverse;
  13695. protected _postMultiplyPivotMatrix: boolean;
  13696. protected _isWorldMatrixFrozen: boolean;
  13697. /** @hidden */
  13698. _indexInSceneTransformNodesArray: number;
  13699. /**
  13700. * An event triggered after the world matrix is updated
  13701. */
  13702. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13703. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13704. /**
  13705. * Gets a string identifying the name of the class
  13706. * @returns "TransformNode" string
  13707. */
  13708. getClassName(): string;
  13709. /**
  13710. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13711. */
  13712. get position(): Vector3;
  13713. set position(newPosition: Vector3);
  13714. /**
  13715. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13716. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13717. */
  13718. get rotation(): Vector3;
  13719. set rotation(newRotation: Vector3);
  13720. /**
  13721. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13722. */
  13723. get scaling(): Vector3;
  13724. set scaling(newScaling: Vector3);
  13725. /**
  13726. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13727. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13728. */
  13729. get rotationQuaternion(): Nullable<Quaternion>;
  13730. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13731. /**
  13732. * The forward direction of that transform in world space.
  13733. */
  13734. get forward(): Vector3;
  13735. /**
  13736. * The up direction of that transform in world space.
  13737. */
  13738. get up(): Vector3;
  13739. /**
  13740. * The right direction of that transform in world space.
  13741. */
  13742. get right(): Vector3;
  13743. /**
  13744. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13745. * @param matrix the matrix to copy the pose from
  13746. * @returns this TransformNode.
  13747. */
  13748. updatePoseMatrix(matrix: Matrix): TransformNode;
  13749. /**
  13750. * Returns the mesh Pose matrix.
  13751. * @returns the pose matrix
  13752. */
  13753. getPoseMatrix(): Matrix;
  13754. /** @hidden */
  13755. _isSynchronized(): boolean;
  13756. /** @hidden */
  13757. _initCache(): void;
  13758. /**
  13759. * Flag the transform node as dirty (Forcing it to update everything)
  13760. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13761. * @returns this transform node
  13762. */
  13763. markAsDirty(property: string): TransformNode;
  13764. /**
  13765. * Returns the current mesh absolute position.
  13766. * Returns a Vector3.
  13767. */
  13768. get absolutePosition(): Vector3;
  13769. /**
  13770. * Returns the current mesh absolute scaling.
  13771. * Returns a Vector3.
  13772. */
  13773. get absoluteScaling(): Vector3;
  13774. /**
  13775. * Returns the current mesh absolute rotation.
  13776. * Returns a Quaternion.
  13777. */
  13778. get absoluteRotationQuaternion(): Quaternion;
  13779. /**
  13780. * Sets a new matrix to apply before all other transformation
  13781. * @param matrix defines the transform matrix
  13782. * @returns the current TransformNode
  13783. */
  13784. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13785. /**
  13786. * Sets a new pivot matrix to the current node
  13787. * @param matrix defines the new pivot matrix to use
  13788. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13792. /**
  13793. * Returns the mesh pivot matrix.
  13794. * Default : Identity.
  13795. * @returns the matrix
  13796. */
  13797. getPivotMatrix(): Matrix;
  13798. /**
  13799. * Instantiate (when possible) or clone that node with its hierarchy
  13800. * @param newParent defines the new parent to use for the instance (or clone)
  13801. * @param options defines options to configure how copy is done
  13802. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13803. * @returns an instance (or a clone) of the current node with its hiearchy
  13804. */
  13805. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13806. doNotInstantiate: boolean;
  13807. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13808. /**
  13809. * Prevents the World matrix to be computed any longer
  13810. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13811. * @returns the TransformNode.
  13812. */
  13813. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13814. /**
  13815. * Allows back the World matrix computation.
  13816. * @returns the TransformNode.
  13817. */
  13818. unfreezeWorldMatrix(): this;
  13819. /**
  13820. * True if the World matrix has been frozen.
  13821. */
  13822. get isWorldMatrixFrozen(): boolean;
  13823. /**
  13824. * Retuns the mesh absolute position in the World.
  13825. * @returns a Vector3.
  13826. */
  13827. getAbsolutePosition(): Vector3;
  13828. /**
  13829. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13830. * @param absolutePosition the absolute position to set
  13831. * @returns the TransformNode.
  13832. */
  13833. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13834. /**
  13835. * Sets the mesh position in its local space.
  13836. * @param vector3 the position to set in localspace
  13837. * @returns the TransformNode.
  13838. */
  13839. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13840. /**
  13841. * Returns the mesh position in the local space from the current World matrix values.
  13842. * @returns a new Vector3.
  13843. */
  13844. getPositionExpressedInLocalSpace(): Vector3;
  13845. /**
  13846. * Translates the mesh along the passed Vector3 in its local space.
  13847. * @param vector3 the distance to translate in localspace
  13848. * @returns the TransformNode.
  13849. */
  13850. locallyTranslate(vector3: Vector3): TransformNode;
  13851. private static _lookAtVectorCache;
  13852. /**
  13853. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13854. * @param targetPoint the position (must be in same space as current mesh) to look at
  13855. * @param yawCor optional yaw (y-axis) correction in radians
  13856. * @param pitchCor optional pitch (x-axis) correction in radians
  13857. * @param rollCor optional roll (z-axis) correction in radians
  13858. * @param space the choosen space of the target
  13859. * @returns the TransformNode.
  13860. */
  13861. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13862. /**
  13863. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13864. * This Vector3 is expressed in the World space.
  13865. * @param localAxis axis to rotate
  13866. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13867. */
  13868. getDirection(localAxis: Vector3): Vector3;
  13869. /**
  13870. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13871. * localAxis is expressed in the mesh local space.
  13872. * result is computed in the Wordl space from the mesh World matrix.
  13873. * @param localAxis axis to rotate
  13874. * @param result the resulting transformnode
  13875. * @returns this TransformNode.
  13876. */
  13877. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13878. /**
  13879. * Sets this transform node rotation to the given local axis.
  13880. * @param localAxis the axis in local space
  13881. * @param yawCor optional yaw (y-axis) correction in radians
  13882. * @param pitchCor optional pitch (x-axis) correction in radians
  13883. * @param rollCor optional roll (z-axis) correction in radians
  13884. * @returns this TransformNode
  13885. */
  13886. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13887. /**
  13888. * Sets a new pivot point to the current node
  13889. * @param point defines the new pivot point to use
  13890. * @param space defines if the point is in world or local space (local by default)
  13891. * @returns the current TransformNode
  13892. */
  13893. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13894. /**
  13895. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13896. * @returns the pivot point
  13897. */
  13898. getPivotPoint(): Vector3;
  13899. /**
  13900. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13901. * @param result the vector3 to store the result
  13902. * @returns this TransformNode.
  13903. */
  13904. getPivotPointToRef(result: Vector3): TransformNode;
  13905. /**
  13906. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13907. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13908. */
  13909. getAbsolutePivotPoint(): Vector3;
  13910. /**
  13911. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13912. * @param result vector3 to store the result
  13913. * @returns this TransformNode.
  13914. */
  13915. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13916. /**
  13917. * Defines the passed node as the parent of the current node.
  13918. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13919. * @see https://doc.babylonjs.com/how_to/parenting
  13920. * @param node the node ot set as the parent
  13921. * @returns this TransformNode.
  13922. */
  13923. setParent(node: Nullable<Node>): TransformNode;
  13924. private _nonUniformScaling;
  13925. /**
  13926. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13927. */
  13928. get nonUniformScaling(): boolean;
  13929. /** @hidden */
  13930. _updateNonUniformScalingState(value: boolean): boolean;
  13931. /**
  13932. * Attach the current TransformNode to another TransformNode associated with a bone
  13933. * @param bone Bone affecting the TransformNode
  13934. * @param affectedTransformNode TransformNode associated with the bone
  13935. * @returns this object
  13936. */
  13937. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13938. /**
  13939. * Detach the transform node if its associated with a bone
  13940. * @returns this object
  13941. */
  13942. detachFromBone(): TransformNode;
  13943. private static _rotationAxisCache;
  13944. /**
  13945. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13946. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13947. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13948. * The passed axis is also normalized.
  13949. * @param axis the axis to rotate around
  13950. * @param amount the amount to rotate in radians
  13951. * @param space Space to rotate in (Default: local)
  13952. * @returns the TransformNode.
  13953. */
  13954. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13955. /**
  13956. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13957. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13958. * The passed axis is also normalized. .
  13959. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13960. * @param point the point to rotate around
  13961. * @param axis the axis to rotate around
  13962. * @param amount the amount to rotate in radians
  13963. * @returns the TransformNode
  13964. */
  13965. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13966. /**
  13967. * Translates the mesh along the axis vector for the passed distance in the given space.
  13968. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13969. * @param axis the axis to translate in
  13970. * @param distance the distance to translate
  13971. * @param space Space to rotate in (Default: local)
  13972. * @returns the TransformNode.
  13973. */
  13974. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13975. /**
  13976. * Adds a rotation step to the mesh current rotation.
  13977. * x, y, z are Euler angles expressed in radians.
  13978. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13979. * This means this rotation is made in the mesh local space only.
  13980. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13981. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13982. * ```javascript
  13983. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13984. * ```
  13985. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13986. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  13987. * @param x Rotation to add
  13988. * @param y Rotation to add
  13989. * @param z Rotation to add
  13990. * @returns the TransformNode.
  13991. */
  13992. addRotation(x: number, y: number, z: number): TransformNode;
  13993. /**
  13994. * @hidden
  13995. */
  13996. protected _getEffectiveParent(): Nullable<Node>;
  13997. /**
  13998. * Computes the world matrix of the node
  13999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14000. * @returns the world matrix
  14001. */
  14002. computeWorldMatrix(force?: boolean): Matrix;
  14003. /**
  14004. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14005. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14006. */
  14007. resetLocalMatrix(independentOfChildren?: boolean): void;
  14008. protected _afterComputeWorldMatrix(): void;
  14009. /**
  14010. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14011. * @param func callback function to add
  14012. *
  14013. * @returns the TransformNode.
  14014. */
  14015. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14016. /**
  14017. * Removes a registered callback function.
  14018. * @param func callback function to remove
  14019. * @returns the TransformNode.
  14020. */
  14021. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14022. /**
  14023. * Gets the position of the current mesh in camera space
  14024. * @param camera defines the camera to use
  14025. * @returns a position
  14026. */
  14027. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14028. /**
  14029. * Returns the distance from the mesh to the active camera
  14030. * @param camera defines the camera to use
  14031. * @returns the distance
  14032. */
  14033. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14034. /**
  14035. * Clone the current transform node
  14036. * @param name Name of the new clone
  14037. * @param newParent New parent for the clone
  14038. * @param doNotCloneChildren Do not clone children hierarchy
  14039. * @returns the new transform node
  14040. */
  14041. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14042. /**
  14043. * Serializes the objects information.
  14044. * @param currentSerializationObject defines the object to serialize in
  14045. * @returns the serialized object
  14046. */
  14047. serialize(currentSerializationObject?: any): any;
  14048. /**
  14049. * Returns a new TransformNode object parsed from the source provided.
  14050. * @param parsedTransformNode is the source.
  14051. * @param scene the scne the object belongs to
  14052. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14053. * @returns a new TransformNode object parsed from the source provided.
  14054. */
  14055. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14056. /**
  14057. * Get all child-transformNodes of this node
  14058. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14059. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14060. * @returns an array of TransformNode
  14061. */
  14062. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14063. /**
  14064. * Releases resources associated with this transform node.
  14065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14067. */
  14068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14069. /**
  14070. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14071. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14072. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14073. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14074. * @returns the current mesh
  14075. */
  14076. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14077. private _syncAbsoluteScalingAndRotation;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * Class used to override all child animations of a given target
  14083. */
  14084. export class AnimationPropertiesOverride {
  14085. /**
  14086. * Gets or sets a value indicating if animation blending must be used
  14087. */
  14088. enableBlending: boolean;
  14089. /**
  14090. * Gets or sets the blending speed to use when enableBlending is true
  14091. */
  14092. blendingSpeed: number;
  14093. /**
  14094. * Gets or sets the default loop mode to use
  14095. */
  14096. loopMode: number;
  14097. }
  14098. }
  14099. declare module BABYLON {
  14100. /**
  14101. * Class used to store bone information
  14102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14103. */
  14104. export class Bone extends Node {
  14105. /**
  14106. * defines the bone name
  14107. */
  14108. name: string;
  14109. private static _tmpVecs;
  14110. private static _tmpQuat;
  14111. private static _tmpMats;
  14112. /**
  14113. * Gets the list of child bones
  14114. */
  14115. children: Bone[];
  14116. /** Gets the animations associated with this bone */
  14117. animations: Animation[];
  14118. /**
  14119. * Gets or sets bone length
  14120. */
  14121. length: number;
  14122. /**
  14123. * @hidden Internal only
  14124. * Set this value to map this bone to a different index in the transform matrices
  14125. * Set this value to -1 to exclude the bone from the transform matrices
  14126. */
  14127. _index: Nullable<number>;
  14128. private _skeleton;
  14129. private _localMatrix;
  14130. private _restPose;
  14131. private _baseMatrix;
  14132. private _absoluteTransform;
  14133. private _invertedAbsoluteTransform;
  14134. private _parent;
  14135. private _scalingDeterminant;
  14136. private _worldTransform;
  14137. private _localScaling;
  14138. private _localRotation;
  14139. private _localPosition;
  14140. private _needToDecompose;
  14141. private _needToCompose;
  14142. /** @hidden */
  14143. _linkedTransformNode: Nullable<TransformNode>;
  14144. /** @hidden */
  14145. _waitingTransformNodeId: Nullable<string>;
  14146. /** @hidden */
  14147. get _matrix(): Matrix;
  14148. /** @hidden */
  14149. set _matrix(value: Matrix);
  14150. /**
  14151. * Create a new bone
  14152. * @param name defines the bone name
  14153. * @param skeleton defines the parent skeleton
  14154. * @param parentBone defines the parent (can be null if the bone is the root)
  14155. * @param localMatrix defines the local matrix
  14156. * @param restPose defines the rest pose matrix
  14157. * @param baseMatrix defines the base matrix
  14158. * @param index defines index of the bone in the hiearchy
  14159. */
  14160. constructor(
  14161. /**
  14162. * defines the bone name
  14163. */
  14164. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14165. /**
  14166. * Gets the current object class name.
  14167. * @return the class name
  14168. */
  14169. getClassName(): string;
  14170. /**
  14171. * Gets the parent skeleton
  14172. * @returns a skeleton
  14173. */
  14174. getSkeleton(): Skeleton;
  14175. /**
  14176. * Gets parent bone
  14177. * @returns a bone or null if the bone is the root of the bone hierarchy
  14178. */
  14179. getParent(): Nullable<Bone>;
  14180. /**
  14181. * Returns an array containing the root bones
  14182. * @returns an array containing the root bones
  14183. */
  14184. getChildren(): Array<Bone>;
  14185. /**
  14186. * Gets the node index in matrix array generated for rendering
  14187. * @returns the node index
  14188. */
  14189. getIndex(): number;
  14190. /**
  14191. * Sets the parent bone
  14192. * @param parent defines the parent (can be null if the bone is the root)
  14193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14194. */
  14195. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14196. /**
  14197. * Gets the local matrix
  14198. * @returns a matrix
  14199. */
  14200. getLocalMatrix(): Matrix;
  14201. /**
  14202. * Gets the base matrix (initial matrix which remains unchanged)
  14203. * @returns a matrix
  14204. */
  14205. getBaseMatrix(): Matrix;
  14206. /**
  14207. * Gets the rest pose matrix
  14208. * @returns a matrix
  14209. */
  14210. getRestPose(): Matrix;
  14211. /**
  14212. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14213. */
  14214. getWorldMatrix(): Matrix;
  14215. /**
  14216. * Sets the local matrix to rest pose matrix
  14217. */
  14218. returnToRest(): void;
  14219. /**
  14220. * Gets the inverse of the absolute transform matrix.
  14221. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14222. * @returns a matrix
  14223. */
  14224. getInvertedAbsoluteTransform(): Matrix;
  14225. /**
  14226. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14227. * @returns a matrix
  14228. */
  14229. getAbsoluteTransform(): Matrix;
  14230. /**
  14231. * Links with the given transform node.
  14232. * The local matrix of this bone is copied from the transform node every frame.
  14233. * @param transformNode defines the transform node to link to
  14234. */
  14235. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14236. /**
  14237. * Gets the node used to drive the bone's transformation
  14238. * @returns a transform node or null
  14239. */
  14240. getTransformNode(): Nullable<TransformNode>;
  14241. /** Gets or sets current position (in local space) */
  14242. get position(): Vector3;
  14243. set position(newPosition: Vector3);
  14244. /** Gets or sets current rotation (in local space) */
  14245. get rotation(): Vector3;
  14246. set rotation(newRotation: Vector3);
  14247. /** Gets or sets current rotation quaternion (in local space) */
  14248. get rotationQuaternion(): Quaternion;
  14249. set rotationQuaternion(newRotation: Quaternion);
  14250. /** Gets or sets current scaling (in local space) */
  14251. get scaling(): Vector3;
  14252. set scaling(newScaling: Vector3);
  14253. /**
  14254. * Gets the animation properties override
  14255. */
  14256. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14257. private _decompose;
  14258. private _compose;
  14259. /**
  14260. * Update the base and local matrices
  14261. * @param matrix defines the new base or local matrix
  14262. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14263. * @param updateLocalMatrix defines if the local matrix should be updated
  14264. */
  14265. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14266. /** @hidden */
  14267. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14268. /**
  14269. * Flag the bone as dirty (Forcing it to update everything)
  14270. */
  14271. markAsDirty(): void;
  14272. /** @hidden */
  14273. _markAsDirtyAndCompose(): void;
  14274. private _markAsDirtyAndDecompose;
  14275. /**
  14276. * Translate the bone in local or world space
  14277. * @param vec The amount to translate the bone
  14278. * @param space The space that the translation is in
  14279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14280. */
  14281. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14282. /**
  14283. * Set the postion of the bone in local or world space
  14284. * @param position The position to set the bone
  14285. * @param space The space that the position is in
  14286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14287. */
  14288. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14289. /**
  14290. * Set the absolute position of the bone (world space)
  14291. * @param position The position to set the bone
  14292. * @param mesh The mesh that this bone is attached to
  14293. */
  14294. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14295. /**
  14296. * Scale the bone on the x, y and z axes (in local space)
  14297. * @param x The amount to scale the bone on the x axis
  14298. * @param y The amount to scale the bone on the y axis
  14299. * @param z The amount to scale the bone on the z axis
  14300. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14301. */
  14302. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14303. /**
  14304. * Set the bone scaling in local space
  14305. * @param scale defines the scaling vector
  14306. */
  14307. setScale(scale: Vector3): void;
  14308. /**
  14309. * Gets the current scaling in local space
  14310. * @returns the current scaling vector
  14311. */
  14312. getScale(): Vector3;
  14313. /**
  14314. * Gets the current scaling in local space and stores it in a target vector
  14315. * @param result defines the target vector
  14316. */
  14317. getScaleToRef(result: Vector3): void;
  14318. /**
  14319. * Set the yaw, pitch, and roll of the bone in local or world space
  14320. * @param yaw The rotation of the bone on the y axis
  14321. * @param pitch The rotation of the bone on the x axis
  14322. * @param roll The rotation of the bone on the z axis
  14323. * @param space The space that the axes of rotation are in
  14324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14325. */
  14326. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14327. /**
  14328. * Add a rotation to the bone on an axis in local or world space
  14329. * @param axis The axis to rotate the bone on
  14330. * @param amount The amount to rotate the bone
  14331. * @param space The space that the axis is in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. */
  14334. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14335. /**
  14336. * Set the rotation of the bone to a particular axis angle in local or world space
  14337. * @param axis The axis to rotate the bone on
  14338. * @param angle The angle that the bone should be rotated to
  14339. * @param space The space that the axis is in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. */
  14342. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14343. /**
  14344. * Set the euler rotation of the bone in local of world space
  14345. * @param rotation The euler rotation that the bone should be set to
  14346. * @param space The space that the rotation is in
  14347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14348. */
  14349. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14350. /**
  14351. * Set the quaternion rotation of the bone in local of world space
  14352. * @param quat The quaternion rotation that the bone should be set to
  14353. * @param space The space that the rotation is in
  14354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14355. */
  14356. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14357. /**
  14358. * Set the rotation matrix of the bone in local of world space
  14359. * @param rotMat The rotation matrix that the bone should be set to
  14360. * @param space The space that the rotation is in
  14361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14362. */
  14363. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14364. private _rotateWithMatrix;
  14365. private _getNegativeRotationToRef;
  14366. /**
  14367. * Get the position of the bone in local or world space
  14368. * @param space The space that the returned position is in
  14369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14370. * @returns The position of the bone
  14371. */
  14372. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14373. /**
  14374. * Copy the position of the bone to a vector3 in local or world space
  14375. * @param space The space that the returned position is in
  14376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14377. * @param result The vector3 to copy the position to
  14378. */
  14379. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14380. /**
  14381. * Get the absolute position of the bone (world space)
  14382. * @param mesh The mesh that this bone is attached to
  14383. * @returns The absolute position of the bone
  14384. */
  14385. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14386. /**
  14387. * Copy the absolute position of the bone (world space) to the result param
  14388. * @param mesh The mesh that this bone is attached to
  14389. * @param result The vector3 to copy the absolute position to
  14390. */
  14391. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14392. /**
  14393. * Compute the absolute transforms of this bone and its children
  14394. */
  14395. computeAbsoluteTransforms(): void;
  14396. /**
  14397. * Get the world direction from an axis that is in the local space of the bone
  14398. * @param localAxis The local direction that is used to compute the world direction
  14399. * @param mesh The mesh that this bone is attached to
  14400. * @returns The world direction
  14401. */
  14402. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14403. /**
  14404. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14405. * @param localAxis The local direction that is used to compute the world direction
  14406. * @param mesh The mesh that this bone is attached to
  14407. * @param result The vector3 that the world direction will be copied to
  14408. */
  14409. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14410. /**
  14411. * Get the euler rotation of the bone in local or world space
  14412. * @param space The space that the rotation should be in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. * @returns The euler rotation
  14415. */
  14416. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14417. /**
  14418. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14419. * @param space The space that the rotation should be in
  14420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14421. * @param result The vector3 that the rotation should be copied to
  14422. */
  14423. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14424. /**
  14425. * Get the quaternion rotation of the bone in either local or world space
  14426. * @param space The space that the rotation should be in
  14427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14428. * @returns The quaternion rotation
  14429. */
  14430. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14431. /**
  14432. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14433. * @param space The space that the rotation should be in
  14434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14435. * @param result The quaternion that the rotation should be copied to
  14436. */
  14437. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14438. /**
  14439. * Get the rotation matrix of the bone in local or world space
  14440. * @param space The space that the rotation should be in
  14441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14442. * @returns The rotation matrix
  14443. */
  14444. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14445. /**
  14446. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14447. * @param space The space that the rotation should be in
  14448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14449. * @param result The quaternion that the rotation should be copied to
  14450. */
  14451. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14452. /**
  14453. * Get the world position of a point that is in the local space of the bone
  14454. * @param position The local position
  14455. * @param mesh The mesh that this bone is attached to
  14456. * @returns The world position
  14457. */
  14458. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14459. /**
  14460. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14461. * @param position The local position
  14462. * @param mesh The mesh that this bone is attached to
  14463. * @param result The vector3 that the world position should be copied to
  14464. */
  14465. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14466. /**
  14467. * Get the local position of a point that is in world space
  14468. * @param position The world position
  14469. * @param mesh The mesh that this bone is attached to
  14470. * @returns The local position
  14471. */
  14472. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14473. /**
  14474. * Get the local position of a point that is in world space and copy it to the result param
  14475. * @param position The world position
  14476. * @param mesh The mesh that this bone is attached to
  14477. * @param result The vector3 that the local position should be copied to
  14478. */
  14479. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14480. }
  14481. }
  14482. declare module BABYLON {
  14483. /**
  14484. * Defines a runtime animation
  14485. */
  14486. export class RuntimeAnimation {
  14487. private _events;
  14488. /**
  14489. * The current frame of the runtime animation
  14490. */
  14491. private _currentFrame;
  14492. /**
  14493. * The animation used by the runtime animation
  14494. */
  14495. private _animation;
  14496. /**
  14497. * The target of the runtime animation
  14498. */
  14499. private _target;
  14500. /**
  14501. * The initiating animatable
  14502. */
  14503. private _host;
  14504. /**
  14505. * The original value of the runtime animation
  14506. */
  14507. private _originalValue;
  14508. /**
  14509. * The original blend value of the runtime animation
  14510. */
  14511. private _originalBlendValue;
  14512. /**
  14513. * The offsets cache of the runtime animation
  14514. */
  14515. private _offsetsCache;
  14516. /**
  14517. * The high limits cache of the runtime animation
  14518. */
  14519. private _highLimitsCache;
  14520. /**
  14521. * Specifies if the runtime animation has been stopped
  14522. */
  14523. private _stopped;
  14524. /**
  14525. * The blending factor of the runtime animation
  14526. */
  14527. private _blendingFactor;
  14528. /**
  14529. * The BabylonJS scene
  14530. */
  14531. private _scene;
  14532. /**
  14533. * The current value of the runtime animation
  14534. */
  14535. private _currentValue;
  14536. /** @hidden */
  14537. _animationState: _IAnimationState;
  14538. /**
  14539. * The active target of the runtime animation
  14540. */
  14541. private _activeTargets;
  14542. private _currentActiveTarget;
  14543. private _directTarget;
  14544. /**
  14545. * The target path of the runtime animation
  14546. */
  14547. private _targetPath;
  14548. /**
  14549. * The weight of the runtime animation
  14550. */
  14551. private _weight;
  14552. /**
  14553. * The ratio offset of the runtime animation
  14554. */
  14555. private _ratioOffset;
  14556. /**
  14557. * The previous delay of the runtime animation
  14558. */
  14559. private _previousDelay;
  14560. /**
  14561. * The previous ratio of the runtime animation
  14562. */
  14563. private _previousRatio;
  14564. private _enableBlending;
  14565. private _keys;
  14566. private _minFrame;
  14567. private _maxFrame;
  14568. private _minValue;
  14569. private _maxValue;
  14570. private _targetIsArray;
  14571. /**
  14572. * Gets the current frame of the runtime animation
  14573. */
  14574. get currentFrame(): number;
  14575. /**
  14576. * Gets the weight of the runtime animation
  14577. */
  14578. get weight(): number;
  14579. /**
  14580. * Gets the current value of the runtime animation
  14581. */
  14582. get currentValue(): any;
  14583. /**
  14584. * Gets the target path of the runtime animation
  14585. */
  14586. get targetPath(): string;
  14587. /**
  14588. * Gets the actual target of the runtime animation
  14589. */
  14590. get target(): any;
  14591. /**
  14592. * Gets the additive state of the runtime animation
  14593. */
  14594. get isAdditive(): boolean;
  14595. /** @hidden */
  14596. _onLoop: () => void;
  14597. /**
  14598. * Create a new RuntimeAnimation object
  14599. * @param target defines the target of the animation
  14600. * @param animation defines the source animation object
  14601. * @param scene defines the hosting scene
  14602. * @param host defines the initiating Animatable
  14603. */
  14604. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14605. private _preparePath;
  14606. /**
  14607. * Gets the animation from the runtime animation
  14608. */
  14609. get animation(): Animation;
  14610. /**
  14611. * Resets the runtime animation to the beginning
  14612. * @param restoreOriginal defines whether to restore the target property to the original value
  14613. */
  14614. reset(restoreOriginal?: boolean): void;
  14615. /**
  14616. * Specifies if the runtime animation is stopped
  14617. * @returns Boolean specifying if the runtime animation is stopped
  14618. */
  14619. isStopped(): boolean;
  14620. /**
  14621. * Disposes of the runtime animation
  14622. */
  14623. dispose(): void;
  14624. /**
  14625. * Apply the interpolated value to the target
  14626. * @param currentValue defines the value computed by the animation
  14627. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14628. */
  14629. setValue(currentValue: any, weight: number): void;
  14630. private _getOriginalValues;
  14631. private _setValue;
  14632. /**
  14633. * Gets the loop pmode of the runtime animation
  14634. * @returns Loop Mode
  14635. */
  14636. private _getCorrectLoopMode;
  14637. /**
  14638. * Move the current animation to a given frame
  14639. * @param frame defines the frame to move to
  14640. */
  14641. goToFrame(frame: number): void;
  14642. /**
  14643. * @hidden Internal use only
  14644. */
  14645. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14646. /**
  14647. * Execute the current animation
  14648. * @param delay defines the delay to add to the current frame
  14649. * @param from defines the lower bound of the animation range
  14650. * @param to defines the upper bound of the animation range
  14651. * @param loop defines if the current animation must loop
  14652. * @param speedRatio defines the current speed ratio
  14653. * @param weight defines the weight of the animation (default is -1 so no weight)
  14654. * @param onLoop optional callback called when animation loops
  14655. * @returns a boolean indicating if the animation is running
  14656. */
  14657. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14658. }
  14659. }
  14660. declare module BABYLON {
  14661. /**
  14662. * Class used to store an actual running animation
  14663. */
  14664. export class Animatable {
  14665. /** defines the target object */
  14666. target: any;
  14667. /** defines the starting frame number (default is 0) */
  14668. fromFrame: number;
  14669. /** defines the ending frame number (default is 100) */
  14670. toFrame: number;
  14671. /** defines if the animation must loop (default is false) */
  14672. loopAnimation: boolean;
  14673. /** defines a callback to call when animation ends if it is not looping */
  14674. onAnimationEnd?: (() => void) | null | undefined;
  14675. /** defines a callback to call when animation loops */
  14676. onAnimationLoop?: (() => void) | null | undefined;
  14677. /** defines whether the animation should be evaluated additively */
  14678. isAdditive: boolean;
  14679. private _localDelayOffset;
  14680. private _pausedDelay;
  14681. private _runtimeAnimations;
  14682. private _paused;
  14683. private _scene;
  14684. private _speedRatio;
  14685. private _weight;
  14686. private _syncRoot;
  14687. /**
  14688. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14689. * This will only apply for non looping animation (default is true)
  14690. */
  14691. disposeOnEnd: boolean;
  14692. /**
  14693. * Gets a boolean indicating if the animation has started
  14694. */
  14695. animationStarted: boolean;
  14696. /**
  14697. * Observer raised when the animation ends
  14698. */
  14699. onAnimationEndObservable: Observable<Animatable>;
  14700. /**
  14701. * Observer raised when the animation loops
  14702. */
  14703. onAnimationLoopObservable: Observable<Animatable>;
  14704. /**
  14705. * Gets the root Animatable used to synchronize and normalize animations
  14706. */
  14707. get syncRoot(): Nullable<Animatable>;
  14708. /**
  14709. * Gets the current frame of the first RuntimeAnimation
  14710. * Used to synchronize Animatables
  14711. */
  14712. get masterFrame(): number;
  14713. /**
  14714. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14715. */
  14716. get weight(): number;
  14717. set weight(value: number);
  14718. /**
  14719. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14720. */
  14721. get speedRatio(): number;
  14722. set speedRatio(value: number);
  14723. /**
  14724. * Creates a new Animatable
  14725. * @param scene defines the hosting scene
  14726. * @param target defines the target object
  14727. * @param fromFrame defines the starting frame number (default is 0)
  14728. * @param toFrame defines the ending frame number (default is 100)
  14729. * @param loopAnimation defines if the animation must loop (default is false)
  14730. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14731. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14732. * @param animations defines a group of animation to add to the new Animatable
  14733. * @param onAnimationLoop defines a callback to call when animation loops
  14734. * @param isAdditive defines whether the animation should be evaluated additively
  14735. */
  14736. constructor(scene: Scene,
  14737. /** defines the target object */
  14738. target: any,
  14739. /** defines the starting frame number (default is 0) */
  14740. fromFrame?: number,
  14741. /** defines the ending frame number (default is 100) */
  14742. toFrame?: number,
  14743. /** defines if the animation must loop (default is false) */
  14744. loopAnimation?: boolean, speedRatio?: number,
  14745. /** defines a callback to call when animation ends if it is not looping */
  14746. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14747. /** defines a callback to call when animation loops */
  14748. onAnimationLoop?: (() => void) | null | undefined,
  14749. /** defines whether the animation should be evaluated additively */
  14750. isAdditive?: boolean);
  14751. /**
  14752. * Synchronize and normalize current Animatable with a source Animatable
  14753. * This is useful when using animation weights and when animations are not of the same length
  14754. * @param root defines the root Animatable to synchronize with
  14755. * @returns the current Animatable
  14756. */
  14757. syncWith(root: Animatable): Animatable;
  14758. /**
  14759. * Gets the list of runtime animations
  14760. * @returns an array of RuntimeAnimation
  14761. */
  14762. getAnimations(): RuntimeAnimation[];
  14763. /**
  14764. * Adds more animations to the current animatable
  14765. * @param target defines the target of the animations
  14766. * @param animations defines the new animations to add
  14767. */
  14768. appendAnimations(target: any, animations: Animation[]): void;
  14769. /**
  14770. * Gets the source animation for a specific property
  14771. * @param property defines the propertyu to look for
  14772. * @returns null or the source animation for the given property
  14773. */
  14774. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14775. /**
  14776. * Gets the runtime animation for a specific property
  14777. * @param property defines the propertyu to look for
  14778. * @returns null or the runtime animation for the given property
  14779. */
  14780. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14781. /**
  14782. * Resets the animatable to its original state
  14783. */
  14784. reset(): void;
  14785. /**
  14786. * Allows the animatable to blend with current running animations
  14787. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14788. * @param blendingSpeed defines the blending speed to use
  14789. */
  14790. enableBlending(blendingSpeed: number): void;
  14791. /**
  14792. * Disable animation blending
  14793. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14794. */
  14795. disableBlending(): void;
  14796. /**
  14797. * Jump directly to a given frame
  14798. * @param frame defines the frame to jump to
  14799. */
  14800. goToFrame(frame: number): void;
  14801. /**
  14802. * Pause the animation
  14803. */
  14804. pause(): void;
  14805. /**
  14806. * Restart the animation
  14807. */
  14808. restart(): void;
  14809. private _raiseOnAnimationEnd;
  14810. /**
  14811. * Stop and delete the current animation
  14812. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14813. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14814. */
  14815. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14816. /**
  14817. * Wait asynchronously for the animation to end
  14818. * @returns a promise which will be fullfilled when the animation ends
  14819. */
  14820. waitAsync(): Promise<Animatable>;
  14821. /** @hidden */
  14822. _animate(delay: number): boolean;
  14823. }
  14824. interface Scene {
  14825. /** @hidden */
  14826. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14827. /** @hidden */
  14828. _processLateAnimationBindingsForMatrices(holder: {
  14829. totalWeight: number;
  14830. totalAdditiveWeight: number;
  14831. animations: RuntimeAnimation[];
  14832. additiveAnimations: RuntimeAnimation[];
  14833. originalValue: Matrix;
  14834. }): any;
  14835. /** @hidden */
  14836. _processLateAnimationBindingsForQuaternions(holder: {
  14837. totalWeight: number;
  14838. totalAdditiveWeight: number;
  14839. animations: RuntimeAnimation[];
  14840. additiveAnimations: RuntimeAnimation[];
  14841. originalValue: Quaternion;
  14842. }, refQuaternion: Quaternion): Quaternion;
  14843. /** @hidden */
  14844. _processLateAnimationBindings(): void;
  14845. /**
  14846. * Will start the animation sequence of a given target
  14847. * @param target defines the target
  14848. * @param from defines from which frame should animation start
  14849. * @param to defines until which frame should animation run.
  14850. * @param weight defines the weight to apply to the animation (1.0 by default)
  14851. * @param loop defines if the animation loops
  14852. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14853. * @param onAnimationEnd defines the function to be executed when the animation ends
  14854. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14855. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14856. * @param onAnimationLoop defines the callback to call when an animation loops
  14857. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14858. * @returns the animatable object created for this animation
  14859. */
  14860. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14861. /**
  14862. * Will start the animation sequence of a given target
  14863. * @param target defines the target
  14864. * @param from defines from which frame should animation start
  14865. * @param to defines until which frame should animation run.
  14866. * @param loop defines if the animation loops
  14867. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14868. * @param onAnimationEnd defines the function to be executed when the animation ends
  14869. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14870. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14871. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14872. * @param onAnimationLoop defines the callback to call when an animation loops
  14873. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14874. * @returns the animatable object created for this animation
  14875. */
  14876. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14877. /**
  14878. * Will start the animation sequence of a given target and its hierarchy
  14879. * @param target defines the target
  14880. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14881. * @param from defines from which frame should animation start
  14882. * @param to defines until which frame should animation run.
  14883. * @param loop defines if the animation loops
  14884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14885. * @param onAnimationEnd defines the function to be executed when the animation ends
  14886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14887. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14888. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14889. * @param onAnimationLoop defines the callback to call when an animation loops
  14890. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14891. * @returns the list of created animatables
  14892. */
  14893. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14894. /**
  14895. * Begin a new animation on a given node
  14896. * @param target defines the target where the animation will take place
  14897. * @param animations defines the list of animations to start
  14898. * @param from defines the initial value
  14899. * @param to defines the final value
  14900. * @param loop defines if you want animation to loop (off by default)
  14901. * @param speedRatio defines the speed ratio to apply to all animations
  14902. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14903. * @param onAnimationLoop defines the callback to call when an animation loops
  14904. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14905. * @returns the list of created animatables
  14906. */
  14907. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14908. /**
  14909. * Begin a new animation on a given node and its hierarchy
  14910. * @param target defines the root node where the animation will take place
  14911. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14912. * @param animations defines the list of animations to start
  14913. * @param from defines the initial value
  14914. * @param to defines the final value
  14915. * @param loop defines if you want animation to loop (off by default)
  14916. * @param speedRatio defines the speed ratio to apply to all animations
  14917. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14918. * @param onAnimationLoop defines the callback to call when an animation loops
  14919. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14920. * @returns the list of animatables created for all nodes
  14921. */
  14922. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14923. /**
  14924. * Gets the animatable associated with a specific target
  14925. * @param target defines the target of the animatable
  14926. * @returns the required animatable if found
  14927. */
  14928. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14929. /**
  14930. * Gets all animatables associated with a given target
  14931. * @param target defines the target to look animatables for
  14932. * @returns an array of Animatables
  14933. */
  14934. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14935. /**
  14936. * Stops and removes all animations that have been applied to the scene
  14937. */
  14938. stopAllAnimations(): void;
  14939. /**
  14940. * Gets the current delta time used by animation engine
  14941. */
  14942. deltaTime: number;
  14943. }
  14944. interface Bone {
  14945. /**
  14946. * Copy an animation range from another bone
  14947. * @param source defines the source bone
  14948. * @param rangeName defines the range name to copy
  14949. * @param frameOffset defines the frame offset
  14950. * @param rescaleAsRequired defines if rescaling must be applied if required
  14951. * @param skelDimensionsRatio defines the scaling ratio
  14952. * @returns true if operation was successful
  14953. */
  14954. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14955. }
  14956. }
  14957. declare module BABYLON {
  14958. /**
  14959. * Class used to handle skinning animations
  14960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14961. */
  14962. export class Skeleton implements IAnimatable {
  14963. /** defines the skeleton name */
  14964. name: string;
  14965. /** defines the skeleton Id */
  14966. id: string;
  14967. /**
  14968. * Defines the list of child bones
  14969. */
  14970. bones: Bone[];
  14971. /**
  14972. * Defines an estimate of the dimension of the skeleton at rest
  14973. */
  14974. dimensionsAtRest: Vector3;
  14975. /**
  14976. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14977. */
  14978. needInitialSkinMatrix: boolean;
  14979. /**
  14980. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14981. */
  14982. overrideMesh: Nullable<AbstractMesh>;
  14983. /**
  14984. * Gets the list of animations attached to this skeleton
  14985. */
  14986. animations: Array<Animation>;
  14987. private _scene;
  14988. private _isDirty;
  14989. private _transformMatrices;
  14990. private _transformMatrixTexture;
  14991. private _meshesWithPoseMatrix;
  14992. private _animatables;
  14993. private _identity;
  14994. private _synchronizedWithMesh;
  14995. private _ranges;
  14996. private _lastAbsoluteTransformsUpdateId;
  14997. private _canUseTextureForBones;
  14998. private _uniqueId;
  14999. /** @hidden */
  15000. _numBonesWithLinkedTransformNode: number;
  15001. /** @hidden */
  15002. _hasWaitingData: Nullable<boolean>;
  15003. /**
  15004. * Specifies if the skeleton should be serialized
  15005. */
  15006. doNotSerialize: boolean;
  15007. private _useTextureToStoreBoneMatrices;
  15008. /**
  15009. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15010. * Please note that this option is not available if the hardware does not support it
  15011. */
  15012. get useTextureToStoreBoneMatrices(): boolean;
  15013. set useTextureToStoreBoneMatrices(value: boolean);
  15014. private _animationPropertiesOverride;
  15015. /**
  15016. * Gets or sets the animation properties override
  15017. */
  15018. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15019. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15020. /**
  15021. * List of inspectable custom properties (used by the Inspector)
  15022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15023. */
  15024. inspectableCustomProperties: IInspectable[];
  15025. /**
  15026. * An observable triggered before computing the skeleton's matrices
  15027. */
  15028. onBeforeComputeObservable: Observable<Skeleton>;
  15029. /**
  15030. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15031. */
  15032. get isUsingTextureForMatrices(): boolean;
  15033. /**
  15034. * Gets the unique ID of this skeleton
  15035. */
  15036. get uniqueId(): number;
  15037. /**
  15038. * Creates a new skeleton
  15039. * @param name defines the skeleton name
  15040. * @param id defines the skeleton Id
  15041. * @param scene defines the hosting scene
  15042. */
  15043. constructor(
  15044. /** defines the skeleton name */
  15045. name: string,
  15046. /** defines the skeleton Id */
  15047. id: string, scene: Scene);
  15048. /**
  15049. * Gets the current object class name.
  15050. * @return the class name
  15051. */
  15052. getClassName(): string;
  15053. /**
  15054. * Returns an array containing the root bones
  15055. * @returns an array containing the root bones
  15056. */
  15057. getChildren(): Array<Bone>;
  15058. /**
  15059. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15060. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15061. * @returns a Float32Array containing matrices data
  15062. */
  15063. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15064. /**
  15065. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15066. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15067. * @returns a raw texture containing the data
  15068. */
  15069. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15070. /**
  15071. * Gets the current hosting scene
  15072. * @returns a scene object
  15073. */
  15074. getScene(): Scene;
  15075. /**
  15076. * Gets a string representing the current skeleton data
  15077. * @param fullDetails defines a boolean indicating if we want a verbose version
  15078. * @returns a string representing the current skeleton data
  15079. */
  15080. toString(fullDetails?: boolean): string;
  15081. /**
  15082. * Get bone's index searching by name
  15083. * @param name defines bone's name to search for
  15084. * @return the indice of the bone. Returns -1 if not found
  15085. */
  15086. getBoneIndexByName(name: string): number;
  15087. /**
  15088. * Creater a new animation range
  15089. * @param name defines the name of the range
  15090. * @param from defines the start key
  15091. * @param to defines the end key
  15092. */
  15093. createAnimationRange(name: string, from: number, to: number): void;
  15094. /**
  15095. * Delete a specific animation range
  15096. * @param name defines the name of the range
  15097. * @param deleteFrames defines if frames must be removed as well
  15098. */
  15099. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15100. /**
  15101. * Gets a specific animation range
  15102. * @param name defines the name of the range to look for
  15103. * @returns the requested animation range or null if not found
  15104. */
  15105. getAnimationRange(name: string): Nullable<AnimationRange>;
  15106. /**
  15107. * Gets the list of all animation ranges defined on this skeleton
  15108. * @returns an array
  15109. */
  15110. getAnimationRanges(): Nullable<AnimationRange>[];
  15111. /**
  15112. * Copy animation range from a source skeleton.
  15113. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15114. * @param source defines the source skeleton
  15115. * @param name defines the name of the range to copy
  15116. * @param rescaleAsRequired defines if rescaling must be applied if required
  15117. * @returns true if operation was successful
  15118. */
  15119. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15120. /**
  15121. * Forces the skeleton to go to rest pose
  15122. */
  15123. returnToRest(): void;
  15124. private _getHighestAnimationFrame;
  15125. /**
  15126. * Begin a specific animation range
  15127. * @param name defines the name of the range to start
  15128. * @param loop defines if looping must be turned on (false by default)
  15129. * @param speedRatio defines the speed ratio to apply (1 by default)
  15130. * @param onAnimationEnd defines a callback which will be called when animation will end
  15131. * @returns a new animatable
  15132. */
  15133. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15134. /**
  15135. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15136. * @param skeleton defines the Skeleton containing the animation range to convert
  15137. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15138. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15139. * @returns the original skeleton
  15140. */
  15141. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15142. /** @hidden */
  15143. _markAsDirty(): void;
  15144. /** @hidden */
  15145. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15146. /** @hidden */
  15147. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15148. private _computeTransformMatrices;
  15149. /**
  15150. * Build all resources required to render a skeleton
  15151. */
  15152. prepare(): void;
  15153. /**
  15154. * Gets the list of animatables currently running for this skeleton
  15155. * @returns an array of animatables
  15156. */
  15157. getAnimatables(): IAnimatable[];
  15158. /**
  15159. * Clone the current skeleton
  15160. * @param name defines the name of the new skeleton
  15161. * @param id defines the id of the new skeleton
  15162. * @returns the new skeleton
  15163. */
  15164. clone(name: string, id?: string): Skeleton;
  15165. /**
  15166. * Enable animation blending for this skeleton
  15167. * @param blendingSpeed defines the blending speed to apply
  15168. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15169. */
  15170. enableBlending(blendingSpeed?: number): void;
  15171. /**
  15172. * Releases all resources associated with the current skeleton
  15173. */
  15174. dispose(): void;
  15175. /**
  15176. * Serialize the skeleton in a JSON object
  15177. * @returns a JSON object
  15178. */
  15179. serialize(): any;
  15180. /**
  15181. * Creates a new skeleton from serialized data
  15182. * @param parsedSkeleton defines the serialized data
  15183. * @param scene defines the hosting scene
  15184. * @returns a new skeleton
  15185. */
  15186. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15187. /**
  15188. * Compute all node absolute transforms
  15189. * @param forceUpdate defines if computation must be done even if cache is up to date
  15190. */
  15191. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15192. /**
  15193. * Gets the root pose matrix
  15194. * @returns a matrix
  15195. */
  15196. getPoseMatrix(): Nullable<Matrix>;
  15197. /**
  15198. * Sorts bones per internal index
  15199. */
  15200. sortBones(): void;
  15201. private _sortBones;
  15202. }
  15203. }
  15204. declare module BABYLON {
  15205. /**
  15206. * Creates an instance based on a source mesh.
  15207. */
  15208. export class InstancedMesh extends AbstractMesh {
  15209. private _sourceMesh;
  15210. private _currentLOD;
  15211. /** @hidden */
  15212. _indexInSourceMeshInstanceArray: number;
  15213. constructor(name: string, source: Mesh);
  15214. /**
  15215. * Returns the string "InstancedMesh".
  15216. */
  15217. getClassName(): string;
  15218. /** Gets the list of lights affecting that mesh */
  15219. get lightSources(): Light[];
  15220. _resyncLightSources(): void;
  15221. _resyncLightSource(light: Light): void;
  15222. _removeLightSource(light: Light, dispose: boolean): void;
  15223. /**
  15224. * If the source mesh receives shadows
  15225. */
  15226. get receiveShadows(): boolean;
  15227. /**
  15228. * The material of the source mesh
  15229. */
  15230. get material(): Nullable<Material>;
  15231. /**
  15232. * Visibility of the source mesh
  15233. */
  15234. get visibility(): number;
  15235. /**
  15236. * Skeleton of the source mesh
  15237. */
  15238. get skeleton(): Nullable<Skeleton>;
  15239. /**
  15240. * Rendering ground id of the source mesh
  15241. */
  15242. get renderingGroupId(): number;
  15243. set renderingGroupId(value: number);
  15244. /**
  15245. * Returns the total number of vertices (integer).
  15246. */
  15247. getTotalVertices(): number;
  15248. /**
  15249. * Returns a positive integer : the total number of indices in this mesh geometry.
  15250. * @returns the numner of indices or zero if the mesh has no geometry.
  15251. */
  15252. getTotalIndices(): number;
  15253. /**
  15254. * The source mesh of the instance
  15255. */
  15256. get sourceMesh(): Mesh;
  15257. /**
  15258. * Is this node ready to be used/rendered
  15259. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15260. * @return {boolean} is it ready
  15261. */
  15262. isReady(completeCheck?: boolean): boolean;
  15263. /**
  15264. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15265. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15266. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15267. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15268. */
  15269. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15270. /**
  15271. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15272. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15273. * The `data` are either a numeric array either a Float32Array.
  15274. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15275. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15276. * Note that a new underlying VertexBuffer object is created each call.
  15277. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15278. *
  15279. * Possible `kind` values :
  15280. * - VertexBuffer.PositionKind
  15281. * - VertexBuffer.UVKind
  15282. * - VertexBuffer.UV2Kind
  15283. * - VertexBuffer.UV3Kind
  15284. * - VertexBuffer.UV4Kind
  15285. * - VertexBuffer.UV5Kind
  15286. * - VertexBuffer.UV6Kind
  15287. * - VertexBuffer.ColorKind
  15288. * - VertexBuffer.MatricesIndicesKind
  15289. * - VertexBuffer.MatricesIndicesExtraKind
  15290. * - VertexBuffer.MatricesWeightsKind
  15291. * - VertexBuffer.MatricesWeightsExtraKind
  15292. *
  15293. * Returns the Mesh.
  15294. */
  15295. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15296. /**
  15297. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15298. * If the mesh has no geometry, it is simply returned as it is.
  15299. * The `data` are either a numeric array either a Float32Array.
  15300. * No new underlying VertexBuffer object is created.
  15301. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15302. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15303. *
  15304. * Possible `kind` values :
  15305. * - VertexBuffer.PositionKind
  15306. * - VertexBuffer.UVKind
  15307. * - VertexBuffer.UV2Kind
  15308. * - VertexBuffer.UV3Kind
  15309. * - VertexBuffer.UV4Kind
  15310. * - VertexBuffer.UV5Kind
  15311. * - VertexBuffer.UV6Kind
  15312. * - VertexBuffer.ColorKind
  15313. * - VertexBuffer.MatricesIndicesKind
  15314. * - VertexBuffer.MatricesIndicesExtraKind
  15315. * - VertexBuffer.MatricesWeightsKind
  15316. * - VertexBuffer.MatricesWeightsExtraKind
  15317. *
  15318. * Returns the Mesh.
  15319. */
  15320. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15321. /**
  15322. * Sets the mesh indices.
  15323. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15324. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15325. * This method creates a new index buffer each call.
  15326. * Returns the Mesh.
  15327. */
  15328. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15329. /**
  15330. * Boolean : True if the mesh owns the requested kind of data.
  15331. */
  15332. isVerticesDataPresent(kind: string): boolean;
  15333. /**
  15334. * Returns an array of indices (IndicesArray).
  15335. */
  15336. getIndices(): Nullable<IndicesArray>;
  15337. get _positions(): Nullable<Vector3[]>;
  15338. /**
  15339. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15340. * This means the mesh underlying bounding box and sphere are recomputed.
  15341. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15342. * @returns the current mesh
  15343. */
  15344. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15345. /** @hidden */
  15346. _preActivate(): InstancedMesh;
  15347. /** @hidden */
  15348. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15349. /** @hidden */
  15350. _postActivate(): void;
  15351. getWorldMatrix(): Matrix;
  15352. get isAnInstance(): boolean;
  15353. /**
  15354. * Returns the current associated LOD AbstractMesh.
  15355. */
  15356. getLOD(camera: Camera): AbstractMesh;
  15357. /** @hidden */
  15358. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15359. /** @hidden */
  15360. _syncSubMeshes(): InstancedMesh;
  15361. /** @hidden */
  15362. _generatePointsArray(): boolean;
  15363. /**
  15364. * Creates a new InstancedMesh from the current mesh.
  15365. * - name (string) : the cloned mesh name
  15366. * - newParent (optional Node) : the optional Node to parent the clone to.
  15367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15368. *
  15369. * Returns the clone.
  15370. */
  15371. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15372. /**
  15373. * Disposes the InstancedMesh.
  15374. * Returns nothing.
  15375. */
  15376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15377. }
  15378. interface Mesh {
  15379. /**
  15380. * Register a custom buffer that will be instanced
  15381. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15382. * @param kind defines the buffer kind
  15383. * @param stride defines the stride in floats
  15384. */
  15385. registerInstancedBuffer(kind: string, stride: number): void;
  15386. /** @hidden */
  15387. _userInstancedBuffersStorage: {
  15388. data: {
  15389. [key: string]: Float32Array;
  15390. };
  15391. sizes: {
  15392. [key: string]: number;
  15393. };
  15394. vertexBuffers: {
  15395. [key: string]: Nullable<VertexBuffer>;
  15396. };
  15397. strides: {
  15398. [key: string]: number;
  15399. };
  15400. };
  15401. }
  15402. interface AbstractMesh {
  15403. /**
  15404. * Object used to store instanced buffers defined by user
  15405. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15406. */
  15407. instancedBuffers: {
  15408. [key: string]: any;
  15409. };
  15410. }
  15411. }
  15412. declare module BABYLON {
  15413. /**
  15414. * Defines the options associated with the creation of a shader material.
  15415. */
  15416. export interface IShaderMaterialOptions {
  15417. /**
  15418. * Does the material work in alpha blend mode
  15419. */
  15420. needAlphaBlending: boolean;
  15421. /**
  15422. * Does the material work in alpha test mode
  15423. */
  15424. needAlphaTesting: boolean;
  15425. /**
  15426. * The list of attribute names used in the shader
  15427. */
  15428. attributes: string[];
  15429. /**
  15430. * The list of unifrom names used in the shader
  15431. */
  15432. uniforms: string[];
  15433. /**
  15434. * The list of UBO names used in the shader
  15435. */
  15436. uniformBuffers: string[];
  15437. /**
  15438. * The list of sampler names used in the shader
  15439. */
  15440. samplers: string[];
  15441. /**
  15442. * The list of defines used in the shader
  15443. */
  15444. defines: string[];
  15445. }
  15446. /**
  15447. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15448. *
  15449. * This returned material effects how the mesh will look based on the code in the shaders.
  15450. *
  15451. * @see http://doc.babylonjs.com/how_to/shader_material
  15452. */
  15453. export class ShaderMaterial extends Material {
  15454. private _shaderPath;
  15455. private _options;
  15456. private _textures;
  15457. private _textureArrays;
  15458. private _floats;
  15459. private _ints;
  15460. private _floatsArrays;
  15461. private _colors3;
  15462. private _colors3Arrays;
  15463. private _colors4;
  15464. private _colors4Arrays;
  15465. private _vectors2;
  15466. private _vectors3;
  15467. private _vectors4;
  15468. private _matrices;
  15469. private _matrixArrays;
  15470. private _matrices3x3;
  15471. private _matrices2x2;
  15472. private _vectors2Arrays;
  15473. private _vectors3Arrays;
  15474. private _vectors4Arrays;
  15475. private _cachedWorldViewMatrix;
  15476. private _cachedWorldViewProjectionMatrix;
  15477. private _renderId;
  15478. private _multiview;
  15479. /**
  15480. * Instantiate a new shader material.
  15481. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15482. * This returned material effects how the mesh will look based on the code in the shaders.
  15483. * @see http://doc.babylonjs.com/how_to/shader_material
  15484. * @param name Define the name of the material in the scene
  15485. * @param scene Define the scene the material belongs to
  15486. * @param shaderPath Defines the route to the shader code in one of three ways:
  15487. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15488. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15489. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15490. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15491. * @param options Define the options used to create the shader
  15492. */
  15493. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15494. /**
  15495. * Gets the shader path used to define the shader code
  15496. * It can be modified to trigger a new compilation
  15497. */
  15498. get shaderPath(): any;
  15499. /**
  15500. * Sets the shader path used to define the shader code
  15501. * It can be modified to trigger a new compilation
  15502. */
  15503. set shaderPath(shaderPath: any);
  15504. /**
  15505. * Gets the options used to compile the shader.
  15506. * They can be modified to trigger a new compilation
  15507. */
  15508. get options(): IShaderMaterialOptions;
  15509. /**
  15510. * Gets the current class name of the material e.g. "ShaderMaterial"
  15511. * Mainly use in serialization.
  15512. * @returns the class name
  15513. */
  15514. getClassName(): string;
  15515. /**
  15516. * Specifies if the material will require alpha blending
  15517. * @returns a boolean specifying if alpha blending is needed
  15518. */
  15519. needAlphaBlending(): boolean;
  15520. /**
  15521. * Specifies if this material should be rendered in alpha test mode
  15522. * @returns a boolean specifying if an alpha test is needed.
  15523. */
  15524. needAlphaTesting(): boolean;
  15525. private _checkUniform;
  15526. /**
  15527. * Set a texture in the shader.
  15528. * @param name Define the name of the uniform samplers as defined in the shader
  15529. * @param texture Define the texture to bind to this sampler
  15530. * @return the material itself allowing "fluent" like uniform updates
  15531. */
  15532. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15533. /**
  15534. * Set a texture array in the shader.
  15535. * @param name Define the name of the uniform sampler array as defined in the shader
  15536. * @param textures Define the list of textures to bind to this sampler
  15537. * @return the material itself allowing "fluent" like uniform updates
  15538. */
  15539. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15540. /**
  15541. * Set a float in the shader.
  15542. * @param name Define the name of the uniform as defined in the shader
  15543. * @param value Define the value to give to the uniform
  15544. * @return the material itself allowing "fluent" like uniform updates
  15545. */
  15546. setFloat(name: string, value: number): ShaderMaterial;
  15547. /**
  15548. * Set a int in the shader.
  15549. * @param name Define the name of the uniform as defined in the shader
  15550. * @param value Define the value to give to the uniform
  15551. * @return the material itself allowing "fluent" like uniform updates
  15552. */
  15553. setInt(name: string, value: number): ShaderMaterial;
  15554. /**
  15555. * Set an array of floats in the shader.
  15556. * @param name Define the name of the uniform as defined in the shader
  15557. * @param value Define the value to give to the uniform
  15558. * @return the material itself allowing "fluent" like uniform updates
  15559. */
  15560. setFloats(name: string, value: number[]): ShaderMaterial;
  15561. /**
  15562. * Set a vec3 in the shader from a Color3.
  15563. * @param name Define the name of the uniform as defined in the shader
  15564. * @param value Define the value to give to the uniform
  15565. * @return the material itself allowing "fluent" like uniform updates
  15566. */
  15567. setColor3(name: string, value: Color3): ShaderMaterial;
  15568. /**
  15569. * Set a vec3 array in the shader from a Color3 array.
  15570. * @param name Define the name of the uniform as defined in the shader
  15571. * @param value Define the value to give to the uniform
  15572. * @return the material itself allowing "fluent" like uniform updates
  15573. */
  15574. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15575. /**
  15576. * Set a vec4 in the shader from a Color4.
  15577. * @param name Define the name of the uniform as defined in the shader
  15578. * @param value Define the value to give to the uniform
  15579. * @return the material itself allowing "fluent" like uniform updates
  15580. */
  15581. setColor4(name: string, value: Color4): ShaderMaterial;
  15582. /**
  15583. * Set a vec4 array in the shader from a Color4 array.
  15584. * @param name Define the name of the uniform as defined in the shader
  15585. * @param value Define the value to give to the uniform
  15586. * @return the material itself allowing "fluent" like uniform updates
  15587. */
  15588. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15589. /**
  15590. * Set a vec2 in the shader from a Vector2.
  15591. * @param name Define the name of the uniform as defined in the shader
  15592. * @param value Define the value to give to the uniform
  15593. * @return the material itself allowing "fluent" like uniform updates
  15594. */
  15595. setVector2(name: string, value: Vector2): ShaderMaterial;
  15596. /**
  15597. * Set a vec3 in the shader from a Vector3.
  15598. * @param name Define the name of the uniform as defined in the shader
  15599. * @param value Define the value to give to the uniform
  15600. * @return the material itself allowing "fluent" like uniform updates
  15601. */
  15602. setVector3(name: string, value: Vector3): ShaderMaterial;
  15603. /**
  15604. * Set a vec4 in the shader from a Vector4.
  15605. * @param name Define the name of the uniform as defined in the shader
  15606. * @param value Define the value to give to the uniform
  15607. * @return the material itself allowing "fluent" like uniform updates
  15608. */
  15609. setVector4(name: string, value: Vector4): ShaderMaterial;
  15610. /**
  15611. * Set a mat4 in the shader from a Matrix.
  15612. * @param name Define the name of the uniform as defined in the shader
  15613. * @param value Define the value to give to the uniform
  15614. * @return the material itself allowing "fluent" like uniform updates
  15615. */
  15616. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15617. /**
  15618. * Set a float32Array in the shader from a matrix array.
  15619. * @param name Define the name of the uniform as defined in the shader
  15620. * @param value Define the value to give to the uniform
  15621. * @return the material itself allowing "fluent" like uniform updates
  15622. */
  15623. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15624. /**
  15625. * Set a mat3 in the shader from a Float32Array.
  15626. * @param name Define the name of the uniform as defined in the shader
  15627. * @param value Define the value to give to the uniform
  15628. * @return the material itself allowing "fluent" like uniform updates
  15629. */
  15630. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15631. /**
  15632. * Set a mat2 in the shader from a Float32Array.
  15633. * @param name Define the name of the uniform as defined in the shader
  15634. * @param value Define the value to give to the uniform
  15635. * @return the material itself allowing "fluent" like uniform updates
  15636. */
  15637. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15638. /**
  15639. * Set a vec2 array in the shader from a number array.
  15640. * @param name Define the name of the uniform as defined in the shader
  15641. * @param value Define the value to give to the uniform
  15642. * @return the material itself allowing "fluent" like uniform updates
  15643. */
  15644. setArray2(name: string, value: number[]): ShaderMaterial;
  15645. /**
  15646. * Set a vec3 array in the shader from a number array.
  15647. * @param name Define the name of the uniform as defined in the shader
  15648. * @param value Define the value to give to the uniform
  15649. * @return the material itself allowing "fluent" like uniform updates
  15650. */
  15651. setArray3(name: string, value: number[]): ShaderMaterial;
  15652. /**
  15653. * Set a vec4 array in the shader from a number array.
  15654. * @param name Define the name of the uniform as defined in the shader
  15655. * @param value Define the value to give to the uniform
  15656. * @return the material itself allowing "fluent" like uniform updates
  15657. */
  15658. setArray4(name: string, value: number[]): ShaderMaterial;
  15659. private _checkCache;
  15660. /**
  15661. * Specifies that the submesh is ready to be used
  15662. * @param mesh defines the mesh to check
  15663. * @param subMesh defines which submesh to check
  15664. * @param useInstances specifies that instances should be used
  15665. * @returns a boolean indicating that the submesh is ready or not
  15666. */
  15667. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15668. /**
  15669. * Checks if the material is ready to render the requested mesh
  15670. * @param mesh Define the mesh to render
  15671. * @param useInstances Define whether or not the material is used with instances
  15672. * @returns true if ready, otherwise false
  15673. */
  15674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15675. /**
  15676. * Binds the world matrix to the material
  15677. * @param world defines the world transformation matrix
  15678. */
  15679. bindOnlyWorldMatrix(world: Matrix): void;
  15680. /**
  15681. * Binds the material to the mesh
  15682. * @param world defines the world transformation matrix
  15683. * @param mesh defines the mesh to bind the material to
  15684. */
  15685. bind(world: Matrix, mesh?: Mesh): void;
  15686. /**
  15687. * Gets the active textures from the material
  15688. * @returns an array of textures
  15689. */
  15690. getActiveTextures(): BaseTexture[];
  15691. /**
  15692. * Specifies if the material uses a texture
  15693. * @param texture defines the texture to check against the material
  15694. * @returns a boolean specifying if the material uses the texture
  15695. */
  15696. hasTexture(texture: BaseTexture): boolean;
  15697. /**
  15698. * Makes a duplicate of the material, and gives it a new name
  15699. * @param name defines the new name for the duplicated material
  15700. * @returns the cloned material
  15701. */
  15702. clone(name: string): ShaderMaterial;
  15703. /**
  15704. * Disposes the material
  15705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15706. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15707. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15708. */
  15709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15710. /**
  15711. * Serializes this material in a JSON representation
  15712. * @returns the serialized material object
  15713. */
  15714. serialize(): any;
  15715. /**
  15716. * Creates a shader material from parsed shader material data
  15717. * @param source defines the JSON represnetation of the material
  15718. * @param scene defines the hosting scene
  15719. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15720. * @returns a new material
  15721. */
  15722. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15723. }
  15724. }
  15725. declare module BABYLON {
  15726. /** @hidden */
  15727. export var colorPixelShader: {
  15728. name: string;
  15729. shader: string;
  15730. };
  15731. }
  15732. declare module BABYLON {
  15733. /** @hidden */
  15734. export var colorVertexShader: {
  15735. name: string;
  15736. shader: string;
  15737. };
  15738. }
  15739. declare module BABYLON {
  15740. /**
  15741. * Line mesh
  15742. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15743. */
  15744. export class LinesMesh extends Mesh {
  15745. /**
  15746. * If vertex color should be applied to the mesh
  15747. */
  15748. readonly useVertexColor?: boolean | undefined;
  15749. /**
  15750. * If vertex alpha should be applied to the mesh
  15751. */
  15752. readonly useVertexAlpha?: boolean | undefined;
  15753. /**
  15754. * Color of the line (Default: White)
  15755. */
  15756. color: Color3;
  15757. /**
  15758. * Alpha of the line (Default: 1)
  15759. */
  15760. alpha: number;
  15761. /**
  15762. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15763. * This margin is expressed in world space coordinates, so its value may vary.
  15764. * Default value is 0.1
  15765. */
  15766. intersectionThreshold: number;
  15767. private _colorShader;
  15768. private color4;
  15769. /**
  15770. * Creates a new LinesMesh
  15771. * @param name defines the name
  15772. * @param scene defines the hosting scene
  15773. * @param parent defines the parent mesh if any
  15774. * @param source defines the optional source LinesMesh used to clone data from
  15775. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15776. * When false, achieved by calling a clone(), also passing False.
  15777. * This will make creation of children, recursive.
  15778. * @param useVertexColor defines if this LinesMesh supports vertex color
  15779. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15780. */
  15781. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15782. /**
  15783. * If vertex color should be applied to the mesh
  15784. */
  15785. useVertexColor?: boolean | undefined,
  15786. /**
  15787. * If vertex alpha should be applied to the mesh
  15788. */
  15789. useVertexAlpha?: boolean | undefined);
  15790. private _addClipPlaneDefine;
  15791. private _removeClipPlaneDefine;
  15792. isReady(): boolean;
  15793. /**
  15794. * Returns the string "LineMesh"
  15795. */
  15796. getClassName(): string;
  15797. /**
  15798. * @hidden
  15799. */
  15800. get material(): Material;
  15801. /**
  15802. * @hidden
  15803. */
  15804. set material(value: Material);
  15805. /**
  15806. * @hidden
  15807. */
  15808. get checkCollisions(): boolean;
  15809. /** @hidden */
  15810. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15811. /** @hidden */
  15812. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15813. /**
  15814. * Disposes of the line mesh
  15815. * @param doNotRecurse If children should be disposed
  15816. */
  15817. dispose(doNotRecurse?: boolean): void;
  15818. /**
  15819. * Returns a new LineMesh object cloned from the current one.
  15820. */
  15821. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15822. /**
  15823. * Creates a new InstancedLinesMesh object from the mesh model.
  15824. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15825. * @param name defines the name of the new instance
  15826. * @returns a new InstancedLinesMesh
  15827. */
  15828. createInstance(name: string): InstancedLinesMesh;
  15829. }
  15830. /**
  15831. * Creates an instance based on a source LinesMesh
  15832. */
  15833. export class InstancedLinesMesh extends InstancedMesh {
  15834. /**
  15835. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15836. * This margin is expressed in world space coordinates, so its value may vary.
  15837. * Initilized with the intersectionThreshold value of the source LinesMesh
  15838. */
  15839. intersectionThreshold: number;
  15840. constructor(name: string, source: LinesMesh);
  15841. /**
  15842. * Returns the string "InstancedLinesMesh".
  15843. */
  15844. getClassName(): string;
  15845. }
  15846. }
  15847. declare module BABYLON {
  15848. /** @hidden */
  15849. export var linePixelShader: {
  15850. name: string;
  15851. shader: string;
  15852. };
  15853. }
  15854. declare module BABYLON {
  15855. /** @hidden */
  15856. export var lineVertexShader: {
  15857. name: string;
  15858. shader: string;
  15859. };
  15860. }
  15861. declare module BABYLON {
  15862. interface AbstractMesh {
  15863. /**
  15864. * Gets the edgesRenderer associated with the mesh
  15865. */
  15866. edgesRenderer: Nullable<EdgesRenderer>;
  15867. }
  15868. interface LinesMesh {
  15869. /**
  15870. * Enables the edge rendering mode on the mesh.
  15871. * This mode makes the mesh edges visible
  15872. * @param epsilon defines the maximal distance between two angles to detect a face
  15873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15874. * @returns the currentAbstractMesh
  15875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15876. */
  15877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15878. }
  15879. interface InstancedLinesMesh {
  15880. /**
  15881. * Enables the edge rendering mode on the mesh.
  15882. * This mode makes the mesh edges visible
  15883. * @param epsilon defines the maximal distance between two angles to detect a face
  15884. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15885. * @returns the current InstancedLinesMesh
  15886. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15887. */
  15888. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15889. }
  15890. /**
  15891. * Defines the minimum contract an Edges renderer should follow.
  15892. */
  15893. export interface IEdgesRenderer extends IDisposable {
  15894. /**
  15895. * Gets or sets a boolean indicating if the edgesRenderer is active
  15896. */
  15897. isEnabled: boolean;
  15898. /**
  15899. * Renders the edges of the attached mesh,
  15900. */
  15901. render(): void;
  15902. /**
  15903. * Checks wether or not the edges renderer is ready to render.
  15904. * @return true if ready, otherwise false.
  15905. */
  15906. isReady(): boolean;
  15907. }
  15908. /**
  15909. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15910. */
  15911. export class EdgesRenderer implements IEdgesRenderer {
  15912. /**
  15913. * Define the size of the edges with an orthographic camera
  15914. */
  15915. edgesWidthScalerForOrthographic: number;
  15916. /**
  15917. * Define the size of the edges with a perspective camera
  15918. */
  15919. edgesWidthScalerForPerspective: number;
  15920. protected _source: AbstractMesh;
  15921. protected _linesPositions: number[];
  15922. protected _linesNormals: number[];
  15923. protected _linesIndices: number[];
  15924. protected _epsilon: number;
  15925. protected _indicesCount: number;
  15926. protected _lineShader: ShaderMaterial;
  15927. protected _ib: DataBuffer;
  15928. protected _buffers: {
  15929. [key: string]: Nullable<VertexBuffer>;
  15930. };
  15931. protected _checkVerticesInsteadOfIndices: boolean;
  15932. private _meshRebuildObserver;
  15933. private _meshDisposeObserver;
  15934. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15935. isEnabled: boolean;
  15936. /**
  15937. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15938. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15939. * @param source Mesh used to create edges
  15940. * @param epsilon sum of angles in adjacency to check for edge
  15941. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15942. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15943. */
  15944. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15945. protected _prepareRessources(): void;
  15946. /** @hidden */
  15947. _rebuild(): void;
  15948. /**
  15949. * Releases the required resources for the edges renderer
  15950. */
  15951. dispose(): void;
  15952. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15953. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15954. /**
  15955. * Checks if the pair of p0 and p1 is en edge
  15956. * @param faceIndex
  15957. * @param edge
  15958. * @param faceNormals
  15959. * @param p0
  15960. * @param p1
  15961. * @private
  15962. */
  15963. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15964. /**
  15965. * push line into the position, normal and index buffer
  15966. * @protected
  15967. */
  15968. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15969. /**
  15970. * Generates lines edges from adjacencjes
  15971. * @private
  15972. */
  15973. _generateEdgesLines(): void;
  15974. /**
  15975. * Checks wether or not the edges renderer is ready to render.
  15976. * @return true if ready, otherwise false.
  15977. */
  15978. isReady(): boolean;
  15979. /**
  15980. * Renders the edges of the attached mesh,
  15981. */
  15982. render(): void;
  15983. }
  15984. /**
  15985. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15986. */
  15987. export class LineEdgesRenderer extends EdgesRenderer {
  15988. /**
  15989. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15990. * @param source LineMesh used to generate edges
  15991. * @param epsilon not important (specified angle for edge detection)
  15992. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15993. */
  15994. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15995. /**
  15996. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15997. */
  15998. _generateEdgesLines(): void;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * This represents the object necessary to create a rendering group.
  16004. * This is exclusively used and created by the rendering manager.
  16005. * To modify the behavior, you use the available helpers in your scene or meshes.
  16006. * @hidden
  16007. */
  16008. export class RenderingGroup {
  16009. index: number;
  16010. private static _zeroVector;
  16011. private _scene;
  16012. private _opaqueSubMeshes;
  16013. private _transparentSubMeshes;
  16014. private _alphaTestSubMeshes;
  16015. private _depthOnlySubMeshes;
  16016. private _particleSystems;
  16017. private _spriteManagers;
  16018. private _opaqueSortCompareFn;
  16019. private _alphaTestSortCompareFn;
  16020. private _transparentSortCompareFn;
  16021. private _renderOpaque;
  16022. private _renderAlphaTest;
  16023. private _renderTransparent;
  16024. /** @hidden */
  16025. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16026. onBeforeTransparentRendering: () => void;
  16027. /**
  16028. * Set the opaque sort comparison function.
  16029. * If null the sub meshes will be render in the order they were created
  16030. */
  16031. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16032. /**
  16033. * Set the alpha test sort comparison function.
  16034. * If null the sub meshes will be render in the order they were created
  16035. */
  16036. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16037. /**
  16038. * Set the transparent sort comparison function.
  16039. * If null the sub meshes will be render in the order they were created
  16040. */
  16041. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16042. /**
  16043. * Creates a new rendering group.
  16044. * @param index The rendering group index
  16045. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16046. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16047. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16048. */
  16049. 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>);
  16050. /**
  16051. * Render all the sub meshes contained in the group.
  16052. * @param customRenderFunction Used to override the default render behaviour of the group.
  16053. * @returns true if rendered some submeshes.
  16054. */
  16055. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16056. /**
  16057. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16058. * @param subMeshes The submeshes to render
  16059. */
  16060. private renderOpaqueSorted;
  16061. /**
  16062. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16063. * @param subMeshes The submeshes to render
  16064. */
  16065. private renderAlphaTestSorted;
  16066. /**
  16067. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16068. * @param subMeshes The submeshes to render
  16069. */
  16070. private renderTransparentSorted;
  16071. /**
  16072. * Renders the submeshes in a specified order.
  16073. * @param subMeshes The submeshes to sort before render
  16074. * @param sortCompareFn The comparison function use to sort
  16075. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16076. * @param transparent Specifies to activate blending if true
  16077. */
  16078. private static renderSorted;
  16079. /**
  16080. * Renders the submeshes in the order they were dispatched (no sort applied).
  16081. * @param subMeshes The submeshes to render
  16082. */
  16083. private static renderUnsorted;
  16084. /**
  16085. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16086. * are rendered back to front if in the same alpha index.
  16087. *
  16088. * @param a The first submesh
  16089. * @param b The second submesh
  16090. * @returns The result of the comparison
  16091. */
  16092. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16093. /**
  16094. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16095. * are rendered back to front.
  16096. *
  16097. * @param a The first submesh
  16098. * @param b The second submesh
  16099. * @returns The result of the comparison
  16100. */
  16101. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16102. /**
  16103. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16104. * are rendered front to back (prevent overdraw).
  16105. *
  16106. * @param a The first submesh
  16107. * @param b The second submesh
  16108. * @returns The result of the comparison
  16109. */
  16110. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16111. /**
  16112. * Resets the different lists of submeshes to prepare a new frame.
  16113. */
  16114. prepare(): void;
  16115. dispose(): void;
  16116. /**
  16117. * Inserts the submesh in its correct queue depending on its material.
  16118. * @param subMesh The submesh to dispatch
  16119. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16120. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16121. */
  16122. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16123. dispatchSprites(spriteManager: ISpriteManager): void;
  16124. dispatchParticles(particleSystem: IParticleSystem): void;
  16125. private _renderParticles;
  16126. private _renderSprites;
  16127. }
  16128. }
  16129. declare module BABYLON {
  16130. /**
  16131. * Interface describing the different options available in the rendering manager
  16132. * regarding Auto Clear between groups.
  16133. */
  16134. export interface IRenderingManagerAutoClearSetup {
  16135. /**
  16136. * Defines whether or not autoclear is enable.
  16137. */
  16138. autoClear: boolean;
  16139. /**
  16140. * Defines whether or not to autoclear the depth buffer.
  16141. */
  16142. depth: boolean;
  16143. /**
  16144. * Defines whether or not to autoclear the stencil buffer.
  16145. */
  16146. stencil: boolean;
  16147. }
  16148. /**
  16149. * This class is used by the onRenderingGroupObservable
  16150. */
  16151. export class RenderingGroupInfo {
  16152. /**
  16153. * The Scene that being rendered
  16154. */
  16155. scene: Scene;
  16156. /**
  16157. * The camera currently used for the rendering pass
  16158. */
  16159. camera: Nullable<Camera>;
  16160. /**
  16161. * The ID of the renderingGroup being processed
  16162. */
  16163. renderingGroupId: number;
  16164. }
  16165. /**
  16166. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16167. * It is enable to manage the different groups as well as the different necessary sort functions.
  16168. * This should not be used directly aside of the few static configurations
  16169. */
  16170. export class RenderingManager {
  16171. /**
  16172. * The max id used for rendering groups (not included)
  16173. */
  16174. static MAX_RENDERINGGROUPS: number;
  16175. /**
  16176. * The min id used for rendering groups (included)
  16177. */
  16178. static MIN_RENDERINGGROUPS: number;
  16179. /**
  16180. * Used to globally prevent autoclearing scenes.
  16181. */
  16182. static AUTOCLEAR: boolean;
  16183. /**
  16184. * @hidden
  16185. */
  16186. _useSceneAutoClearSetup: boolean;
  16187. private _scene;
  16188. private _renderingGroups;
  16189. private _depthStencilBufferAlreadyCleaned;
  16190. private _autoClearDepthStencil;
  16191. private _customOpaqueSortCompareFn;
  16192. private _customAlphaTestSortCompareFn;
  16193. private _customTransparentSortCompareFn;
  16194. private _renderingGroupInfo;
  16195. /**
  16196. * Instantiates a new rendering group for a particular scene
  16197. * @param scene Defines the scene the groups belongs to
  16198. */
  16199. constructor(scene: Scene);
  16200. private _clearDepthStencilBuffer;
  16201. /**
  16202. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16203. * @hidden
  16204. */
  16205. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16206. /**
  16207. * Resets the different information of the group to prepare a new frame
  16208. * @hidden
  16209. */
  16210. reset(): void;
  16211. /**
  16212. * Dispose and release the group and its associated resources.
  16213. * @hidden
  16214. */
  16215. dispose(): void;
  16216. /**
  16217. * Clear the info related to rendering groups preventing retention points during dispose.
  16218. */
  16219. freeRenderingGroups(): void;
  16220. private _prepareRenderingGroup;
  16221. /**
  16222. * Add a sprite manager to the rendering manager in order to render it this frame.
  16223. * @param spriteManager Define the sprite manager to render
  16224. */
  16225. dispatchSprites(spriteManager: ISpriteManager): void;
  16226. /**
  16227. * Add a particle system to the rendering manager in order to render it this frame.
  16228. * @param particleSystem Define the particle system to render
  16229. */
  16230. dispatchParticles(particleSystem: IParticleSystem): void;
  16231. /**
  16232. * Add a submesh to the manager in order to render it this frame
  16233. * @param subMesh The submesh to dispatch
  16234. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16235. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16236. */
  16237. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16238. /**
  16239. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16240. * This allowed control for front to back rendering or reversly depending of the special needs.
  16241. *
  16242. * @param renderingGroupId The rendering group id corresponding to its index
  16243. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16244. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16245. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16246. */
  16247. 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;
  16248. /**
  16249. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16250. *
  16251. * @param renderingGroupId The rendering group id corresponding to its index
  16252. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16253. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16254. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16255. */
  16256. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16257. /**
  16258. * Gets the current auto clear configuration for one rendering group of the rendering
  16259. * manager.
  16260. * @param index the rendering group index to get the information for
  16261. * @returns The auto clear setup for the requested rendering group
  16262. */
  16263. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16264. }
  16265. }
  16266. declare module BABYLON {
  16267. /**
  16268. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16269. */
  16270. export interface ICustomShaderOptions {
  16271. /**
  16272. * Gets or sets the custom shader name to use
  16273. */
  16274. shaderName: string;
  16275. /**
  16276. * The list of attribute names used in the shader
  16277. */
  16278. attributes?: string[];
  16279. /**
  16280. * The list of unifrom names used in the shader
  16281. */
  16282. uniforms?: string[];
  16283. /**
  16284. * The list of sampler names used in the shader
  16285. */
  16286. samplers?: string[];
  16287. /**
  16288. * The list of defines used in the shader
  16289. */
  16290. defines?: string[];
  16291. }
  16292. /**
  16293. * Interface to implement to create a shadow generator compatible with BJS.
  16294. */
  16295. export interface IShadowGenerator {
  16296. /**
  16297. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16298. * @returns The render target texture if present otherwise, null
  16299. */
  16300. getShadowMap(): Nullable<RenderTargetTexture>;
  16301. /**
  16302. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16303. * @param subMesh The submesh we want to render in the shadow map
  16304. * @param useInstances Defines wether will draw in the map using instances
  16305. * @returns true if ready otherwise, false
  16306. */
  16307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16308. /**
  16309. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16310. * @param defines Defines of the material we want to update
  16311. * @param lightIndex Index of the light in the enabled light list of the material
  16312. */
  16313. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16314. /**
  16315. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16316. * defined in the generator but impacting the effect).
  16317. * It implies the unifroms available on the materials are the standard BJS ones.
  16318. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16319. * @param effect The effect we are binfing the information for
  16320. */
  16321. bindShadowLight(lightIndex: string, effect: Effect): void;
  16322. /**
  16323. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16324. * (eq to shadow prjection matrix * light transform matrix)
  16325. * @returns The transform matrix used to create the shadow map
  16326. */
  16327. getTransformMatrix(): Matrix;
  16328. /**
  16329. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16330. * Cube and 2D textures for instance.
  16331. */
  16332. recreateShadowMap(): void;
  16333. /**
  16334. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16335. * @param onCompiled Callback triggered at the and of the effects compilation
  16336. * @param options Sets of optional options forcing the compilation with different modes
  16337. */
  16338. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16339. useInstances: boolean;
  16340. }>): void;
  16341. /**
  16342. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16343. * @param options Sets of optional options forcing the compilation with different modes
  16344. * @returns A promise that resolves when the compilation completes
  16345. */
  16346. forceCompilationAsync(options?: Partial<{
  16347. useInstances: boolean;
  16348. }>): Promise<void>;
  16349. /**
  16350. * Serializes the shadow generator setup to a json object.
  16351. * @returns The serialized JSON object
  16352. */
  16353. serialize(): any;
  16354. /**
  16355. * Disposes the Shadow map and related Textures and effects.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. /**
  16360. * Default implementation IShadowGenerator.
  16361. * This is the main object responsible of generating shadows in the framework.
  16362. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16363. */
  16364. export class ShadowGenerator implements IShadowGenerator {
  16365. /**
  16366. * Name of the shadow generator class
  16367. */
  16368. static CLASSNAME: string;
  16369. /**
  16370. * Shadow generator mode None: no filtering applied.
  16371. */
  16372. static readonly FILTER_NONE: number;
  16373. /**
  16374. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16375. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16376. */
  16377. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16378. /**
  16379. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16380. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16381. */
  16382. static readonly FILTER_POISSONSAMPLING: number;
  16383. /**
  16384. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16385. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16386. */
  16387. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16388. /**
  16389. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16390. * edge artifacts on steep falloff.
  16391. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16392. */
  16393. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16394. /**
  16395. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16396. * edge artifacts on steep falloff.
  16397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16398. */
  16399. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16400. /**
  16401. * Shadow generator mode PCF: Percentage Closer Filtering
  16402. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16403. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16404. */
  16405. static readonly FILTER_PCF: number;
  16406. /**
  16407. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16408. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16409. * Contact Hardening
  16410. */
  16411. static readonly FILTER_PCSS: number;
  16412. /**
  16413. * Reserved for PCF and PCSS
  16414. * Highest Quality.
  16415. *
  16416. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16417. *
  16418. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16419. */
  16420. static readonly QUALITY_HIGH: number;
  16421. /**
  16422. * Reserved for PCF and PCSS
  16423. * Good tradeoff for quality/perf cross devices
  16424. *
  16425. * Execute PCF on a 3*3 kernel.
  16426. *
  16427. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16428. */
  16429. static readonly QUALITY_MEDIUM: number;
  16430. /**
  16431. * Reserved for PCF and PCSS
  16432. * The lowest quality but the fastest.
  16433. *
  16434. * Execute PCF on a 1*1 kernel.
  16435. *
  16436. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16437. */
  16438. static readonly QUALITY_LOW: number;
  16439. /** Gets or sets the custom shader name to use */
  16440. customShaderOptions: ICustomShaderOptions;
  16441. /**
  16442. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16443. */
  16444. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16445. /**
  16446. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16447. */
  16448. onAfterShadowMapRenderObservable: Observable<Effect>;
  16449. /**
  16450. * Observable triggered before a mesh is rendered in the shadow map.
  16451. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16452. */
  16453. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16454. /**
  16455. * Observable triggered after a mesh is rendered in the shadow map.
  16456. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16457. */
  16458. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16459. protected _bias: number;
  16460. /**
  16461. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16462. */
  16463. get bias(): number;
  16464. /**
  16465. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16466. */
  16467. set bias(bias: number);
  16468. protected _normalBias: number;
  16469. /**
  16470. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16471. */
  16472. get normalBias(): number;
  16473. /**
  16474. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16475. */
  16476. set normalBias(normalBias: number);
  16477. protected _blurBoxOffset: number;
  16478. /**
  16479. * Gets the blur box offset: offset applied during the blur pass.
  16480. * Only useful if useKernelBlur = false
  16481. */
  16482. get blurBoxOffset(): number;
  16483. /**
  16484. * Sets the blur box offset: offset applied during the blur pass.
  16485. * Only useful if useKernelBlur = false
  16486. */
  16487. set blurBoxOffset(value: number);
  16488. protected _blurScale: number;
  16489. /**
  16490. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16491. * 2 means half of the size.
  16492. */
  16493. get blurScale(): number;
  16494. /**
  16495. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16496. * 2 means half of the size.
  16497. */
  16498. set blurScale(value: number);
  16499. protected _blurKernel: number;
  16500. /**
  16501. * Gets the blur kernel: kernel size of the blur pass.
  16502. * Only useful if useKernelBlur = true
  16503. */
  16504. get blurKernel(): number;
  16505. /**
  16506. * Sets the blur kernel: kernel size of the blur pass.
  16507. * Only useful if useKernelBlur = true
  16508. */
  16509. set blurKernel(value: number);
  16510. protected _useKernelBlur: boolean;
  16511. /**
  16512. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16513. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16514. */
  16515. get useKernelBlur(): boolean;
  16516. /**
  16517. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16518. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16519. */
  16520. set useKernelBlur(value: boolean);
  16521. protected _depthScale: number;
  16522. /**
  16523. * Gets the depth scale used in ESM mode.
  16524. */
  16525. get depthScale(): number;
  16526. /**
  16527. * Sets the depth scale used in ESM mode.
  16528. * This can override the scale stored on the light.
  16529. */
  16530. set depthScale(value: number);
  16531. protected _validateFilter(filter: number): number;
  16532. protected _filter: number;
  16533. /**
  16534. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16535. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16536. */
  16537. get filter(): number;
  16538. /**
  16539. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16540. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16541. */
  16542. set filter(value: number);
  16543. /**
  16544. * Gets if the current filter is set to Poisson Sampling.
  16545. */
  16546. get usePoissonSampling(): boolean;
  16547. /**
  16548. * Sets the current filter to Poisson Sampling.
  16549. */
  16550. set usePoissonSampling(value: boolean);
  16551. /**
  16552. * Gets if the current filter is set to ESM.
  16553. */
  16554. get useExponentialShadowMap(): boolean;
  16555. /**
  16556. * Sets the current filter is to ESM.
  16557. */
  16558. set useExponentialShadowMap(value: boolean);
  16559. /**
  16560. * Gets if the current filter is set to filtered ESM.
  16561. */
  16562. get useBlurExponentialShadowMap(): boolean;
  16563. /**
  16564. * Gets if the current filter is set to filtered ESM.
  16565. */
  16566. set useBlurExponentialShadowMap(value: boolean);
  16567. /**
  16568. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16569. * exponential to prevent steep falloff artifacts).
  16570. */
  16571. get useCloseExponentialShadowMap(): boolean;
  16572. /**
  16573. * Sets the current filter to "close ESM" (using the inverse of the
  16574. * exponential to prevent steep falloff artifacts).
  16575. */
  16576. set useCloseExponentialShadowMap(value: boolean);
  16577. /**
  16578. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16579. * exponential to prevent steep falloff artifacts).
  16580. */
  16581. get useBlurCloseExponentialShadowMap(): boolean;
  16582. /**
  16583. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16584. * exponential to prevent steep falloff artifacts).
  16585. */
  16586. set useBlurCloseExponentialShadowMap(value: boolean);
  16587. /**
  16588. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16589. */
  16590. get usePercentageCloserFiltering(): boolean;
  16591. /**
  16592. * Sets the current filter to "PCF" (percentage closer filtering).
  16593. */
  16594. set usePercentageCloserFiltering(value: boolean);
  16595. protected _filteringQuality: number;
  16596. /**
  16597. * Gets the PCF or PCSS Quality.
  16598. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16599. */
  16600. get filteringQuality(): number;
  16601. /**
  16602. * Sets the PCF or PCSS Quality.
  16603. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16604. */
  16605. set filteringQuality(filteringQuality: number);
  16606. /**
  16607. * Gets if the current filter is set to "PCSS" (contact hardening).
  16608. */
  16609. get useContactHardeningShadow(): boolean;
  16610. /**
  16611. * Sets the current filter to "PCSS" (contact hardening).
  16612. */
  16613. set useContactHardeningShadow(value: boolean);
  16614. protected _contactHardeningLightSizeUVRatio: number;
  16615. /**
  16616. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16617. * Using a ratio helps keeping shape stability independently of the map size.
  16618. *
  16619. * It does not account for the light projection as it was having too much
  16620. * instability during the light setup or during light position changes.
  16621. *
  16622. * Only valid if useContactHardeningShadow is true.
  16623. */
  16624. get contactHardeningLightSizeUVRatio(): number;
  16625. /**
  16626. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16627. * Using a ratio helps keeping shape stability independently of the map size.
  16628. *
  16629. * It does not account for the light projection as it was having too much
  16630. * instability during the light setup or during light position changes.
  16631. *
  16632. * Only valid if useContactHardeningShadow is true.
  16633. */
  16634. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16635. protected _darkness: number;
  16636. /** Gets or sets the actual darkness of a shadow */
  16637. get darkness(): number;
  16638. set darkness(value: number);
  16639. /**
  16640. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16641. * 0 means strongest and 1 would means no shadow.
  16642. * @returns the darkness.
  16643. */
  16644. getDarkness(): number;
  16645. /**
  16646. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16647. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16648. * @returns the shadow generator allowing fluent coding.
  16649. */
  16650. setDarkness(darkness: number): ShadowGenerator;
  16651. protected _transparencyShadow: boolean;
  16652. /** Gets or sets the ability to have transparent shadow */
  16653. get transparencyShadow(): boolean;
  16654. set transparencyShadow(value: boolean);
  16655. /**
  16656. * Sets the ability to have transparent shadow (boolean).
  16657. * @param transparent True if transparent else False
  16658. * @returns the shadow generator allowing fluent coding
  16659. */
  16660. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16661. protected _shadowMap: Nullable<RenderTargetTexture>;
  16662. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16663. /**
  16664. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16665. * @returns The render target texture if present otherwise, null
  16666. */
  16667. getShadowMap(): Nullable<RenderTargetTexture>;
  16668. /**
  16669. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16670. * @returns The render target texture if the shadow map is present otherwise, null
  16671. */
  16672. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16673. /**
  16674. * Gets the class name of that object
  16675. * @returns "ShadowGenerator"
  16676. */
  16677. getClassName(): string;
  16678. /**
  16679. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16680. * @param mesh Mesh to add
  16681. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16682. * @returns the Shadow Generator itself
  16683. */
  16684. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16685. /**
  16686. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16687. * @param mesh Mesh to remove
  16688. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16689. * @returns the Shadow Generator itself
  16690. */
  16691. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16692. /**
  16693. * Controls the extent to which the shadows fade out at the edge of the frustum
  16694. */
  16695. frustumEdgeFalloff: number;
  16696. protected _light: IShadowLight;
  16697. /**
  16698. * Returns the associated light object.
  16699. * @returns the light generating the shadow
  16700. */
  16701. getLight(): IShadowLight;
  16702. /**
  16703. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16704. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16705. * It might on the other hand introduce peter panning.
  16706. */
  16707. forceBackFacesOnly: boolean;
  16708. protected _scene: Scene;
  16709. protected _lightDirection: Vector3;
  16710. protected _effect: Effect;
  16711. protected _viewMatrix: Matrix;
  16712. protected _projectionMatrix: Matrix;
  16713. protected _transformMatrix: Matrix;
  16714. protected _cachedPosition: Vector3;
  16715. protected _cachedDirection: Vector3;
  16716. protected _cachedDefines: string;
  16717. protected _currentRenderID: number;
  16718. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16719. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16720. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16721. protected _blurPostProcesses: PostProcess[];
  16722. protected _mapSize: number;
  16723. protected _currentFaceIndex: number;
  16724. protected _currentFaceIndexCache: number;
  16725. protected _textureType: number;
  16726. protected _defaultTextureMatrix: Matrix;
  16727. protected _storedUniqueId: Nullable<number>;
  16728. /** @hidden */
  16729. static _SceneComponentInitialization: (scene: Scene) => void;
  16730. /**
  16731. * Creates a ShadowGenerator object.
  16732. * A ShadowGenerator is the required tool to use the shadows.
  16733. * Each light casting shadows needs to use its own ShadowGenerator.
  16734. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16735. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16736. * @param light The light object generating the shadows.
  16737. * @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.
  16738. */
  16739. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16740. protected _initializeGenerator(): void;
  16741. protected _createTargetRenderTexture(): void;
  16742. protected _initializeShadowMap(): void;
  16743. protected _initializeBlurRTTAndPostProcesses(): void;
  16744. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16745. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16746. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16747. protected _applyFilterValues(): void;
  16748. /**
  16749. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16750. * @param onCompiled Callback triggered at the and of the effects compilation
  16751. * @param options Sets of optional options forcing the compilation with different modes
  16752. */
  16753. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16754. useInstances: boolean;
  16755. }>): void;
  16756. /**
  16757. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16758. * @param options Sets of optional options forcing the compilation with different modes
  16759. * @returns A promise that resolves when the compilation completes
  16760. */
  16761. forceCompilationAsync(options?: Partial<{
  16762. useInstances: boolean;
  16763. }>): Promise<void>;
  16764. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16765. /**
  16766. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16767. * @param subMesh The submesh we want to render in the shadow map
  16768. * @param useInstances Defines wether will draw in the map using instances
  16769. * @returns true if ready otherwise, false
  16770. */
  16771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16772. /**
  16773. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16774. * @param defines Defines of the material we want to update
  16775. * @param lightIndex Index of the light in the enabled light list of the material
  16776. */
  16777. prepareDefines(defines: any, lightIndex: number): void;
  16778. /**
  16779. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16780. * defined in the generator but impacting the effect).
  16781. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16782. * @param effect The effect we are binfing the information for
  16783. */
  16784. bindShadowLight(lightIndex: string, effect: Effect): void;
  16785. /**
  16786. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16787. * (eq to shadow prjection matrix * light transform matrix)
  16788. * @returns The transform matrix used to create the shadow map
  16789. */
  16790. getTransformMatrix(): Matrix;
  16791. /**
  16792. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16793. * Cube and 2D textures for instance.
  16794. */
  16795. recreateShadowMap(): void;
  16796. protected _disposeBlurPostProcesses(): void;
  16797. protected _disposeRTTandPostProcesses(): void;
  16798. /**
  16799. * Disposes the ShadowGenerator.
  16800. * Returns nothing.
  16801. */
  16802. dispose(): void;
  16803. /**
  16804. * Serializes the shadow generator setup to a json object.
  16805. * @returns The serialized JSON object
  16806. */
  16807. serialize(): any;
  16808. /**
  16809. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16810. * @param parsedShadowGenerator The JSON object to parse
  16811. * @param scene The scene to create the shadow map for
  16812. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16813. * @returns The parsed shadow generator
  16814. */
  16815. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16816. }
  16817. }
  16818. declare module BABYLON {
  16819. /**
  16820. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16821. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16822. * 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.
  16823. */
  16824. export abstract class Light extends Node {
  16825. /**
  16826. * Falloff Default: light is falling off following the material specification:
  16827. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16828. */
  16829. static readonly FALLOFF_DEFAULT: number;
  16830. /**
  16831. * Falloff Physical: light is falling off following the inverse squared distance law.
  16832. */
  16833. static readonly FALLOFF_PHYSICAL: number;
  16834. /**
  16835. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16836. * to enhance interoperability with other engines.
  16837. */
  16838. static readonly FALLOFF_GLTF: number;
  16839. /**
  16840. * Falloff Standard: light is falling off like in the standard material
  16841. * to enhance interoperability with other materials.
  16842. */
  16843. static readonly FALLOFF_STANDARD: number;
  16844. /**
  16845. * If every light affecting the material is in this lightmapMode,
  16846. * material.lightmapTexture adds or multiplies
  16847. * (depends on material.useLightmapAsShadowmap)
  16848. * after every other light calculations.
  16849. */
  16850. static readonly LIGHTMAP_DEFAULT: number;
  16851. /**
  16852. * material.lightmapTexture as only diffuse lighting from this light
  16853. * adds only specular lighting from this light
  16854. * adds dynamic shadows
  16855. */
  16856. static readonly LIGHTMAP_SPECULAR: number;
  16857. /**
  16858. * material.lightmapTexture as only lighting
  16859. * no light calculation from this light
  16860. * only adds dynamic shadows from this light
  16861. */
  16862. static readonly LIGHTMAP_SHADOWSONLY: number;
  16863. /**
  16864. * Each light type uses the default quantity according to its type:
  16865. * point/spot lights use luminous intensity
  16866. * directional lights use illuminance
  16867. */
  16868. static readonly INTENSITYMODE_AUTOMATIC: number;
  16869. /**
  16870. * lumen (lm)
  16871. */
  16872. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16873. /**
  16874. * candela (lm/sr)
  16875. */
  16876. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16877. /**
  16878. * lux (lm/m^2)
  16879. */
  16880. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16881. /**
  16882. * nit (cd/m^2)
  16883. */
  16884. static readonly INTENSITYMODE_LUMINANCE: number;
  16885. /**
  16886. * Light type const id of the point light.
  16887. */
  16888. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16889. /**
  16890. * Light type const id of the directional light.
  16891. */
  16892. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16893. /**
  16894. * Light type const id of the spot light.
  16895. */
  16896. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16897. /**
  16898. * Light type const id of the hemispheric light.
  16899. */
  16900. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16901. /**
  16902. * Diffuse gives the basic color to an object.
  16903. */
  16904. diffuse: Color3;
  16905. /**
  16906. * Specular produces a highlight color on an object.
  16907. * Note: This is note affecting PBR materials.
  16908. */
  16909. specular: Color3;
  16910. /**
  16911. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16912. * falling off base on range or angle.
  16913. * This can be set to any values in Light.FALLOFF_x.
  16914. *
  16915. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16916. * other types of materials.
  16917. */
  16918. falloffType: number;
  16919. /**
  16920. * Strength of the light.
  16921. * Note: By default it is define in the framework own unit.
  16922. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16923. */
  16924. intensity: number;
  16925. private _range;
  16926. protected _inverseSquaredRange: number;
  16927. /**
  16928. * Defines how far from the source the light is impacting in scene units.
  16929. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16930. */
  16931. get range(): number;
  16932. /**
  16933. * Defines how far from the source the light is impacting in scene units.
  16934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16935. */
  16936. set range(value: number);
  16937. /**
  16938. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16939. * of light.
  16940. */
  16941. private _photometricScale;
  16942. private _intensityMode;
  16943. /**
  16944. * Gets the photometric scale used to interpret the intensity.
  16945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16946. */
  16947. get intensityMode(): number;
  16948. /**
  16949. * Sets the photometric scale used to interpret the intensity.
  16950. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16951. */
  16952. set intensityMode(value: number);
  16953. private _radius;
  16954. /**
  16955. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16956. */
  16957. get radius(): number;
  16958. /**
  16959. * sets the light radius used by PBR Materials to simulate soft area lights.
  16960. */
  16961. set radius(value: number);
  16962. private _renderPriority;
  16963. /**
  16964. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16965. * exceeding the number allowed of the materials.
  16966. */
  16967. renderPriority: number;
  16968. private _shadowEnabled;
  16969. /**
  16970. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16971. * the current shadow generator.
  16972. */
  16973. get shadowEnabled(): boolean;
  16974. /**
  16975. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16976. * the current shadow generator.
  16977. */
  16978. set shadowEnabled(value: boolean);
  16979. private _includedOnlyMeshes;
  16980. /**
  16981. * Gets the only meshes impacted by this light.
  16982. */
  16983. get includedOnlyMeshes(): AbstractMesh[];
  16984. /**
  16985. * Sets the only meshes impacted by this light.
  16986. */
  16987. set includedOnlyMeshes(value: AbstractMesh[]);
  16988. private _excludedMeshes;
  16989. /**
  16990. * Gets the meshes not impacted by this light.
  16991. */
  16992. get excludedMeshes(): AbstractMesh[];
  16993. /**
  16994. * Sets the meshes not impacted by this light.
  16995. */
  16996. set excludedMeshes(value: AbstractMesh[]);
  16997. private _excludeWithLayerMask;
  16998. /**
  16999. * Gets the layer id use to find what meshes are not impacted by the light.
  17000. * Inactive if 0
  17001. */
  17002. get excludeWithLayerMask(): number;
  17003. /**
  17004. * Sets the layer id use to find what meshes are not impacted by the light.
  17005. * Inactive if 0
  17006. */
  17007. set excludeWithLayerMask(value: number);
  17008. private _includeOnlyWithLayerMask;
  17009. /**
  17010. * Gets the layer id use to find what meshes are impacted by the light.
  17011. * Inactive if 0
  17012. */
  17013. get includeOnlyWithLayerMask(): number;
  17014. /**
  17015. * Sets the layer id use to find what meshes are impacted by the light.
  17016. * Inactive if 0
  17017. */
  17018. set includeOnlyWithLayerMask(value: number);
  17019. private _lightmapMode;
  17020. /**
  17021. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17022. */
  17023. get lightmapMode(): number;
  17024. /**
  17025. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17026. */
  17027. set lightmapMode(value: number);
  17028. /**
  17029. * Shadow generator associted to the light.
  17030. * @hidden Internal use only.
  17031. */
  17032. _shadowGenerator: Nullable<IShadowGenerator>;
  17033. /**
  17034. * @hidden Internal use only.
  17035. */
  17036. _excludedMeshesIds: string[];
  17037. /**
  17038. * @hidden Internal use only.
  17039. */
  17040. _includedOnlyMeshesIds: string[];
  17041. /**
  17042. * The current light unifom buffer.
  17043. * @hidden Internal use only.
  17044. */
  17045. _uniformBuffer: UniformBuffer;
  17046. /** @hidden */
  17047. _renderId: number;
  17048. /**
  17049. * Creates a Light object in the scene.
  17050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17051. * @param name The firendly name of the light
  17052. * @param scene The scene the light belongs too
  17053. */
  17054. constructor(name: string, scene: Scene);
  17055. protected abstract _buildUniformLayout(): void;
  17056. /**
  17057. * Sets the passed Effect "effect" with the Light information.
  17058. * @param effect The effect to update
  17059. * @param lightIndex The index of the light in the effect to update
  17060. * @returns The light
  17061. */
  17062. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17063. /**
  17064. * Sets the passed Effect "effect" with the Light textures.
  17065. * @param effect The effect to update
  17066. * @param lightIndex The index of the light in the effect to update
  17067. * @returns The light
  17068. */
  17069. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17070. /**
  17071. * Binds the lights information from the scene to the effect for the given mesh.
  17072. * @param lightIndex Light index
  17073. * @param scene The scene where the light belongs to
  17074. * @param effect The effect we are binding the data to
  17075. * @param useSpecular Defines if specular is supported
  17076. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17077. */
  17078. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17079. /**
  17080. * Sets the passed Effect "effect" with the Light information.
  17081. * @param effect The effect to update
  17082. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17083. * @returns The light
  17084. */
  17085. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17086. /**
  17087. * Returns the string "Light".
  17088. * @returns the class name
  17089. */
  17090. getClassName(): string;
  17091. /** @hidden */
  17092. readonly _isLight: boolean;
  17093. /**
  17094. * Converts the light information to a readable string for debug purpose.
  17095. * @param fullDetails Supports for multiple levels of logging within scene loading
  17096. * @returns the human readable light info
  17097. */
  17098. toString(fullDetails?: boolean): string;
  17099. /** @hidden */
  17100. protected _syncParentEnabledState(): void;
  17101. /**
  17102. * Set the enabled state of this node.
  17103. * @param value - the new enabled state
  17104. */
  17105. setEnabled(value: boolean): void;
  17106. /**
  17107. * Returns the Light associated shadow generator if any.
  17108. * @return the associated shadow generator.
  17109. */
  17110. getShadowGenerator(): Nullable<IShadowGenerator>;
  17111. /**
  17112. * Returns a Vector3, the absolute light position in the World.
  17113. * @returns the world space position of the light
  17114. */
  17115. getAbsolutePosition(): Vector3;
  17116. /**
  17117. * Specifies if the light will affect the passed mesh.
  17118. * @param mesh The mesh to test against the light
  17119. * @return true the mesh is affected otherwise, false.
  17120. */
  17121. canAffectMesh(mesh: AbstractMesh): boolean;
  17122. /**
  17123. * Sort function to order lights for rendering.
  17124. * @param a First Light object to compare to second.
  17125. * @param b Second Light object to compare first.
  17126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17127. */
  17128. static CompareLightsPriority(a: Light, b: Light): number;
  17129. /**
  17130. * Releases resources associated with this node.
  17131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17133. */
  17134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17135. /**
  17136. * Returns the light type ID (integer).
  17137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17138. */
  17139. getTypeID(): number;
  17140. /**
  17141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17142. * @returns the scaled intensity in intensity mode unit
  17143. */
  17144. getScaledIntensity(): number;
  17145. /**
  17146. * Returns a new Light object, named "name", from the current one.
  17147. * @param name The name of the cloned light
  17148. * @returns the new created light
  17149. */
  17150. clone(name: string): Nullable<Light>;
  17151. /**
  17152. * Serializes the current light into a Serialization object.
  17153. * @returns the serialized object.
  17154. */
  17155. serialize(): any;
  17156. /**
  17157. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17158. * This new light is named "name" and added to the passed scene.
  17159. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17160. * @param name The friendly name of the light
  17161. * @param scene The scene the new light will belong to
  17162. * @returns the constructor function
  17163. */
  17164. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17165. /**
  17166. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17167. * @param parsedLight The JSON representation of the light
  17168. * @param scene The scene to create the parsed light in
  17169. * @returns the created light after parsing
  17170. */
  17171. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17172. private _hookArrayForExcluded;
  17173. private _hookArrayForIncludedOnly;
  17174. private _resyncMeshes;
  17175. /**
  17176. * Forces the meshes to update their light related information in their rendering used effects
  17177. * @hidden Internal Use Only
  17178. */
  17179. _markMeshesAsLightDirty(): void;
  17180. /**
  17181. * Recomputes the cached photometric scale if needed.
  17182. */
  17183. private _computePhotometricScale;
  17184. /**
  17185. * Returns the Photometric Scale according to the light type and intensity mode.
  17186. */
  17187. private _getPhotometricScale;
  17188. /**
  17189. * Reorder the light in the scene according to their defined priority.
  17190. * @hidden Internal Use Only
  17191. */
  17192. _reorderLightsInScene(): void;
  17193. /**
  17194. * Prepares the list of defines specific to the light type.
  17195. * @param defines the list of defines
  17196. * @param lightIndex defines the index of the light for the effect
  17197. */
  17198. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17199. }
  17200. }
  17201. declare module BABYLON {
  17202. /**
  17203. * Interface used to define Action
  17204. */
  17205. export interface IAction {
  17206. /**
  17207. * Trigger for the action
  17208. */
  17209. trigger: number;
  17210. /** Options of the trigger */
  17211. triggerOptions: any;
  17212. /**
  17213. * Gets the trigger parameters
  17214. * @returns the trigger parameters
  17215. */
  17216. getTriggerParameter(): any;
  17217. /**
  17218. * Internal only - executes current action event
  17219. * @hidden
  17220. */
  17221. _executeCurrent(evt?: ActionEvent): void;
  17222. /**
  17223. * Serialize placeholder for child classes
  17224. * @param parent of child
  17225. * @returns the serialized object
  17226. */
  17227. serialize(parent: any): any;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. _prepare(): void;
  17233. /**
  17234. * Internal only - manager for action
  17235. * @hidden
  17236. */
  17237. _actionManager: AbstractActionManager;
  17238. /**
  17239. * Adds action to chain of actions, may be a DoNothingAction
  17240. * @param action defines the next action to execute
  17241. * @returns The action passed in
  17242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17243. */
  17244. then(action: IAction): IAction;
  17245. }
  17246. /**
  17247. * The action to be carried out following a trigger
  17248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17249. */
  17250. export class Action implements IAction {
  17251. /** the trigger, with or without parameters, for the action */
  17252. triggerOptions: any;
  17253. /**
  17254. * Trigger for the action
  17255. */
  17256. trigger: number;
  17257. /**
  17258. * Internal only - manager for action
  17259. * @hidden
  17260. */
  17261. _actionManager: ActionManager;
  17262. private _nextActiveAction;
  17263. private _child;
  17264. private _condition?;
  17265. private _triggerParameter;
  17266. /**
  17267. * An event triggered prior to action being executed.
  17268. */
  17269. onBeforeExecuteObservable: Observable<Action>;
  17270. /**
  17271. * Creates a new Action
  17272. * @param triggerOptions the trigger, with or without parameters, for the action
  17273. * @param condition an optional determinant of action
  17274. */
  17275. constructor(
  17276. /** the trigger, with or without parameters, for the action */
  17277. triggerOptions: any, condition?: Condition);
  17278. /**
  17279. * Internal only
  17280. * @hidden
  17281. */
  17282. _prepare(): void;
  17283. /**
  17284. * Gets the trigger parameters
  17285. * @returns the trigger parameters
  17286. */
  17287. getTriggerParameter(): any;
  17288. /**
  17289. * Internal only - executes current action event
  17290. * @hidden
  17291. */
  17292. _executeCurrent(evt?: ActionEvent): void;
  17293. /**
  17294. * Execute placeholder for child classes
  17295. * @param evt optional action event
  17296. */
  17297. execute(evt?: ActionEvent): void;
  17298. /**
  17299. * Skips to next active action
  17300. */
  17301. skipToNextActiveAction(): void;
  17302. /**
  17303. * Adds action to chain of actions, may be a DoNothingAction
  17304. * @param action defines the next action to execute
  17305. * @returns The action passed in
  17306. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17307. */
  17308. then(action: Action): Action;
  17309. /**
  17310. * Internal only
  17311. * @hidden
  17312. */
  17313. _getProperty(propertyPath: string): string;
  17314. /**
  17315. * Internal only
  17316. * @hidden
  17317. */
  17318. _getEffectiveTarget(target: any, propertyPath: string): any;
  17319. /**
  17320. * Serialize placeholder for child classes
  17321. * @param parent of child
  17322. * @returns the serialized object
  17323. */
  17324. serialize(parent: any): any;
  17325. /**
  17326. * Internal only called by serialize
  17327. * @hidden
  17328. */
  17329. protected _serialize(serializedAction: any, parent?: any): any;
  17330. /**
  17331. * Internal only
  17332. * @hidden
  17333. */
  17334. static _SerializeValueAsString: (value: any) => string;
  17335. /**
  17336. * Internal only
  17337. * @hidden
  17338. */
  17339. static _GetTargetProperty: (target: Node | Scene) => {
  17340. name: string;
  17341. targetType: string;
  17342. value: string;
  17343. };
  17344. }
  17345. }
  17346. declare module BABYLON {
  17347. /**
  17348. * A Condition applied to an Action
  17349. */
  17350. export class Condition {
  17351. /**
  17352. * Internal only - manager for action
  17353. * @hidden
  17354. */
  17355. _actionManager: ActionManager;
  17356. /**
  17357. * Internal only
  17358. * @hidden
  17359. */
  17360. _evaluationId: number;
  17361. /**
  17362. * Internal only
  17363. * @hidden
  17364. */
  17365. _currentResult: boolean;
  17366. /**
  17367. * Creates a new Condition
  17368. * @param actionManager the manager of the action the condition is applied to
  17369. */
  17370. constructor(actionManager: ActionManager);
  17371. /**
  17372. * Check if the current condition is valid
  17373. * @returns a boolean
  17374. */
  17375. isValid(): boolean;
  17376. /**
  17377. * Internal only
  17378. * @hidden
  17379. */
  17380. _getProperty(propertyPath: string): string;
  17381. /**
  17382. * Internal only
  17383. * @hidden
  17384. */
  17385. _getEffectiveTarget(target: any, propertyPath: string): any;
  17386. /**
  17387. * Serialize placeholder for child classes
  17388. * @returns the serialized object
  17389. */
  17390. serialize(): any;
  17391. /**
  17392. * Internal only
  17393. * @hidden
  17394. */
  17395. protected _serialize(serializedCondition: any): any;
  17396. }
  17397. /**
  17398. * Defines specific conditional operators as extensions of Condition
  17399. */
  17400. export class ValueCondition extends Condition {
  17401. /** path to specify the property of the target the conditional operator uses */
  17402. propertyPath: string;
  17403. /** the value compared by the conditional operator against the current value of the property */
  17404. value: any;
  17405. /** the conditional operator, default ValueCondition.IsEqual */
  17406. operator: number;
  17407. /**
  17408. * Internal only
  17409. * @hidden
  17410. */
  17411. private static _IsEqual;
  17412. /**
  17413. * Internal only
  17414. * @hidden
  17415. */
  17416. private static _IsDifferent;
  17417. /**
  17418. * Internal only
  17419. * @hidden
  17420. */
  17421. private static _IsGreater;
  17422. /**
  17423. * Internal only
  17424. * @hidden
  17425. */
  17426. private static _IsLesser;
  17427. /**
  17428. * returns the number for IsEqual
  17429. */
  17430. static get IsEqual(): number;
  17431. /**
  17432. * Returns the number for IsDifferent
  17433. */
  17434. static get IsDifferent(): number;
  17435. /**
  17436. * Returns the number for IsGreater
  17437. */
  17438. static get IsGreater(): number;
  17439. /**
  17440. * Returns the number for IsLesser
  17441. */
  17442. static get IsLesser(): number;
  17443. /**
  17444. * Internal only The action manager for the condition
  17445. * @hidden
  17446. */
  17447. _actionManager: ActionManager;
  17448. /**
  17449. * Internal only
  17450. * @hidden
  17451. */
  17452. private _target;
  17453. /**
  17454. * Internal only
  17455. * @hidden
  17456. */
  17457. private _effectiveTarget;
  17458. /**
  17459. * Internal only
  17460. * @hidden
  17461. */
  17462. private _property;
  17463. /**
  17464. * Creates a new ValueCondition
  17465. * @param actionManager manager for the action the condition applies to
  17466. * @param target for the action
  17467. * @param propertyPath path to specify the property of the target the conditional operator uses
  17468. * @param value the value compared by the conditional operator against the current value of the property
  17469. * @param operator the conditional operator, default ValueCondition.IsEqual
  17470. */
  17471. constructor(actionManager: ActionManager, target: any,
  17472. /** path to specify the property of the target the conditional operator uses */
  17473. propertyPath: string,
  17474. /** the value compared by the conditional operator against the current value of the property */
  17475. value: any,
  17476. /** the conditional operator, default ValueCondition.IsEqual */
  17477. operator?: number);
  17478. /**
  17479. * Compares the given value with the property value for the specified conditional operator
  17480. * @returns the result of the comparison
  17481. */
  17482. isValid(): boolean;
  17483. /**
  17484. * Serialize the ValueCondition into a JSON compatible object
  17485. * @returns serialization object
  17486. */
  17487. serialize(): any;
  17488. /**
  17489. * Gets the name of the conditional operator for the ValueCondition
  17490. * @param operator the conditional operator
  17491. * @returns the name
  17492. */
  17493. static GetOperatorName(operator: number): string;
  17494. }
  17495. /**
  17496. * Defines a predicate condition as an extension of Condition
  17497. */
  17498. export class PredicateCondition extends Condition {
  17499. /** defines the predicate function used to validate the condition */
  17500. predicate: () => boolean;
  17501. /**
  17502. * Internal only - manager for action
  17503. * @hidden
  17504. */
  17505. _actionManager: ActionManager;
  17506. /**
  17507. * Creates a new PredicateCondition
  17508. * @param actionManager manager for the action the condition applies to
  17509. * @param predicate defines the predicate function used to validate the condition
  17510. */
  17511. constructor(actionManager: ActionManager,
  17512. /** defines the predicate function used to validate the condition */
  17513. predicate: () => boolean);
  17514. /**
  17515. * @returns the validity of the predicate condition
  17516. */
  17517. isValid(): boolean;
  17518. }
  17519. /**
  17520. * Defines a state condition as an extension of Condition
  17521. */
  17522. export class StateCondition extends Condition {
  17523. /** Value to compare with target state */
  17524. value: string;
  17525. /**
  17526. * Internal only - manager for action
  17527. * @hidden
  17528. */
  17529. _actionManager: ActionManager;
  17530. /**
  17531. * Internal only
  17532. * @hidden
  17533. */
  17534. private _target;
  17535. /**
  17536. * Creates a new StateCondition
  17537. * @param actionManager manager for the action the condition applies to
  17538. * @param target of the condition
  17539. * @param value to compare with target state
  17540. */
  17541. constructor(actionManager: ActionManager, target: any,
  17542. /** Value to compare with target state */
  17543. value: string);
  17544. /**
  17545. * Gets a boolean indicating if the current condition is met
  17546. * @returns the validity of the state
  17547. */
  17548. isValid(): boolean;
  17549. /**
  17550. * Serialize the StateCondition into a JSON compatible object
  17551. * @returns serialization object
  17552. */
  17553. serialize(): any;
  17554. }
  17555. }
  17556. declare module BABYLON {
  17557. /**
  17558. * This defines an action responsible to toggle a boolean once triggered.
  17559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17560. */
  17561. export class SwitchBooleanAction extends Action {
  17562. /**
  17563. * The path to the boolean property in the target object
  17564. */
  17565. propertyPath: string;
  17566. private _target;
  17567. private _effectiveTarget;
  17568. private _property;
  17569. /**
  17570. * Instantiate the action
  17571. * @param triggerOptions defines the trigger options
  17572. * @param target defines the object containing the boolean
  17573. * @param propertyPath defines the path to the boolean property in the target object
  17574. * @param condition defines the trigger related conditions
  17575. */
  17576. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17577. /** @hidden */
  17578. _prepare(): void;
  17579. /**
  17580. * Execute the action toggle the boolean value.
  17581. */
  17582. execute(): void;
  17583. /**
  17584. * Serializes the actions and its related information.
  17585. * @param parent defines the object to serialize in
  17586. * @returns the serialized object
  17587. */
  17588. serialize(parent: any): any;
  17589. }
  17590. /**
  17591. * This defines an action responsible to set a the state field of the target
  17592. * to a desired value once triggered.
  17593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17594. */
  17595. export class SetStateAction extends Action {
  17596. /**
  17597. * The value to store in the state field.
  17598. */
  17599. value: string;
  17600. private _target;
  17601. /**
  17602. * Instantiate the action
  17603. * @param triggerOptions defines the trigger options
  17604. * @param target defines the object containing the state property
  17605. * @param value defines the value to store in the state field
  17606. * @param condition defines the trigger related conditions
  17607. */
  17608. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17609. /**
  17610. * Execute the action and store the value on the target state property.
  17611. */
  17612. execute(): void;
  17613. /**
  17614. * Serializes the actions and its related information.
  17615. * @param parent defines the object to serialize in
  17616. * @returns the serialized object
  17617. */
  17618. serialize(parent: any): any;
  17619. }
  17620. /**
  17621. * This defines an action responsible to set a property of the target
  17622. * to a desired value once triggered.
  17623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17624. */
  17625. export class SetValueAction extends Action {
  17626. /**
  17627. * The path of the property to set in the target.
  17628. */
  17629. propertyPath: string;
  17630. /**
  17631. * The value to set in the property
  17632. */
  17633. value: any;
  17634. private _target;
  17635. private _effectiveTarget;
  17636. private _property;
  17637. /**
  17638. * Instantiate the action
  17639. * @param triggerOptions defines the trigger options
  17640. * @param target defines the object containing the property
  17641. * @param propertyPath defines the path of the property to set in the target
  17642. * @param value defines the value to set in the property
  17643. * @param condition defines the trigger related conditions
  17644. */
  17645. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17646. /** @hidden */
  17647. _prepare(): void;
  17648. /**
  17649. * Execute the action and set the targetted property to the desired value.
  17650. */
  17651. execute(): void;
  17652. /**
  17653. * Serializes the actions and its related information.
  17654. * @param parent defines the object to serialize in
  17655. * @returns the serialized object
  17656. */
  17657. serialize(parent: any): any;
  17658. }
  17659. /**
  17660. * This defines an action responsible to increment the target value
  17661. * to a desired value once triggered.
  17662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17663. */
  17664. export class IncrementValueAction extends Action {
  17665. /**
  17666. * The path of the property to increment in the target.
  17667. */
  17668. propertyPath: string;
  17669. /**
  17670. * The value we should increment the property by.
  17671. */
  17672. value: any;
  17673. private _target;
  17674. private _effectiveTarget;
  17675. private _property;
  17676. /**
  17677. * Instantiate the action
  17678. * @param triggerOptions defines the trigger options
  17679. * @param target defines the object containing the property
  17680. * @param propertyPath defines the path of the property to increment in the target
  17681. * @param value defines the value value we should increment the property by
  17682. * @param condition defines the trigger related conditions
  17683. */
  17684. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17685. /** @hidden */
  17686. _prepare(): void;
  17687. /**
  17688. * Execute the action and increment the target of the value amount.
  17689. */
  17690. execute(): void;
  17691. /**
  17692. * Serializes the actions and its related information.
  17693. * @param parent defines the object to serialize in
  17694. * @returns the serialized object
  17695. */
  17696. serialize(parent: any): any;
  17697. }
  17698. /**
  17699. * This defines an action responsible to start an animation once triggered.
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17701. */
  17702. export class PlayAnimationAction extends Action {
  17703. /**
  17704. * Where the animation should start (animation frame)
  17705. */
  17706. from: number;
  17707. /**
  17708. * Where the animation should stop (animation frame)
  17709. */
  17710. to: number;
  17711. /**
  17712. * Define if the animation should loop or stop after the first play.
  17713. */
  17714. loop?: boolean;
  17715. private _target;
  17716. /**
  17717. * Instantiate the action
  17718. * @param triggerOptions defines the trigger options
  17719. * @param target defines the target animation or animation name
  17720. * @param from defines from where the animation should start (animation frame)
  17721. * @param end defines where the animation should stop (animation frame)
  17722. * @param loop defines if the animation should loop or stop after the first play
  17723. * @param condition defines the trigger related conditions
  17724. */
  17725. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17726. /** @hidden */
  17727. _prepare(): void;
  17728. /**
  17729. * Execute the action and play the animation.
  17730. */
  17731. execute(): void;
  17732. /**
  17733. * Serializes the actions and its related information.
  17734. * @param parent defines the object to serialize in
  17735. * @returns the serialized object
  17736. */
  17737. serialize(parent: any): any;
  17738. }
  17739. /**
  17740. * This defines an action responsible to stop an animation once triggered.
  17741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17742. */
  17743. export class StopAnimationAction extends Action {
  17744. private _target;
  17745. /**
  17746. * Instantiate the action
  17747. * @param triggerOptions defines the trigger options
  17748. * @param target defines the target animation or animation name
  17749. * @param condition defines the trigger related conditions
  17750. */
  17751. constructor(triggerOptions: any, target: any, condition?: Condition);
  17752. /** @hidden */
  17753. _prepare(): void;
  17754. /**
  17755. * Execute the action and stop the animation.
  17756. */
  17757. execute(): void;
  17758. /**
  17759. * Serializes the actions and its related information.
  17760. * @param parent defines the object to serialize in
  17761. * @returns the serialized object
  17762. */
  17763. serialize(parent: any): any;
  17764. }
  17765. /**
  17766. * This defines an action responsible that does nothing once triggered.
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17768. */
  17769. export class DoNothingAction extends Action {
  17770. /**
  17771. * Instantiate the action
  17772. * @param triggerOptions defines the trigger options
  17773. * @param condition defines the trigger related conditions
  17774. */
  17775. constructor(triggerOptions?: any, condition?: Condition);
  17776. /**
  17777. * Execute the action and do nothing.
  17778. */
  17779. execute(): void;
  17780. /**
  17781. * Serializes the actions and its related information.
  17782. * @param parent defines the object to serialize in
  17783. * @returns the serialized object
  17784. */
  17785. serialize(parent: any): any;
  17786. }
  17787. /**
  17788. * This defines an action responsible to trigger several actions once triggered.
  17789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17790. */
  17791. export class CombineAction extends Action {
  17792. /**
  17793. * The list of aggregated animations to run.
  17794. */
  17795. children: Action[];
  17796. /**
  17797. * Instantiate the action
  17798. * @param triggerOptions defines the trigger options
  17799. * @param children defines the list of aggregated animations to run
  17800. * @param condition defines the trigger related conditions
  17801. */
  17802. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17803. /** @hidden */
  17804. _prepare(): void;
  17805. /**
  17806. * Execute the action and executes all the aggregated actions.
  17807. */
  17808. execute(evt: ActionEvent): void;
  17809. /**
  17810. * Serializes the actions and its related information.
  17811. * @param parent defines the object to serialize in
  17812. * @returns the serialized object
  17813. */
  17814. serialize(parent: any): any;
  17815. }
  17816. /**
  17817. * This defines an action responsible to run code (external event) once triggered.
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17819. */
  17820. export class ExecuteCodeAction extends Action {
  17821. /**
  17822. * The callback function to run.
  17823. */
  17824. func: (evt: ActionEvent) => void;
  17825. /**
  17826. * Instantiate the action
  17827. * @param triggerOptions defines the trigger options
  17828. * @param func defines the callback function to run
  17829. * @param condition defines the trigger related conditions
  17830. */
  17831. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17832. /**
  17833. * Execute the action and run the attached code.
  17834. */
  17835. execute(evt: ActionEvent): void;
  17836. }
  17837. /**
  17838. * This defines an action responsible to set the parent property of the target once triggered.
  17839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17840. */
  17841. export class SetParentAction extends Action {
  17842. private _parent;
  17843. private _target;
  17844. /**
  17845. * Instantiate the action
  17846. * @param triggerOptions defines the trigger options
  17847. * @param target defines the target containing the parent property
  17848. * @param parent defines from where the animation should start (animation frame)
  17849. * @param condition defines the trigger related conditions
  17850. */
  17851. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17852. /** @hidden */
  17853. _prepare(): void;
  17854. /**
  17855. * Execute the action and set the parent property.
  17856. */
  17857. execute(): void;
  17858. /**
  17859. * Serializes the actions and its related information.
  17860. * @param parent defines the object to serialize in
  17861. * @returns the serialized object
  17862. */
  17863. serialize(parent: any): any;
  17864. }
  17865. }
  17866. declare module BABYLON {
  17867. /**
  17868. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17869. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17871. */
  17872. export class ActionManager extends AbstractActionManager {
  17873. /**
  17874. * Nothing
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17876. */
  17877. static readonly NothingTrigger: number;
  17878. /**
  17879. * On pick
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17881. */
  17882. static readonly OnPickTrigger: number;
  17883. /**
  17884. * On left pick
  17885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17886. */
  17887. static readonly OnLeftPickTrigger: number;
  17888. /**
  17889. * On right pick
  17890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17891. */
  17892. static readonly OnRightPickTrigger: number;
  17893. /**
  17894. * On center pick
  17895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17896. */
  17897. static readonly OnCenterPickTrigger: number;
  17898. /**
  17899. * On pick down
  17900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17901. */
  17902. static readonly OnPickDownTrigger: number;
  17903. /**
  17904. * On double pick
  17905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17906. */
  17907. static readonly OnDoublePickTrigger: number;
  17908. /**
  17909. * On pick up
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17911. */
  17912. static readonly OnPickUpTrigger: number;
  17913. /**
  17914. * On pick out.
  17915. * This trigger will only be raised if you also declared a OnPickDown
  17916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17917. */
  17918. static readonly OnPickOutTrigger: number;
  17919. /**
  17920. * On long press
  17921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17922. */
  17923. static readonly OnLongPressTrigger: number;
  17924. /**
  17925. * On pointer over
  17926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17927. */
  17928. static readonly OnPointerOverTrigger: number;
  17929. /**
  17930. * On pointer out
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17932. */
  17933. static readonly OnPointerOutTrigger: number;
  17934. /**
  17935. * On every frame
  17936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17937. */
  17938. static readonly OnEveryFrameTrigger: number;
  17939. /**
  17940. * On intersection enter
  17941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17942. */
  17943. static readonly OnIntersectionEnterTrigger: number;
  17944. /**
  17945. * On intersection exit
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17947. */
  17948. static readonly OnIntersectionExitTrigger: number;
  17949. /**
  17950. * On key down
  17951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17952. */
  17953. static readonly OnKeyDownTrigger: number;
  17954. /**
  17955. * On key up
  17956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17957. */
  17958. static readonly OnKeyUpTrigger: number;
  17959. private _scene;
  17960. /**
  17961. * Creates a new action manager
  17962. * @param scene defines the hosting scene
  17963. */
  17964. constructor(scene: Scene);
  17965. /**
  17966. * Releases all associated resources
  17967. */
  17968. dispose(): void;
  17969. /**
  17970. * Gets hosting scene
  17971. * @returns the hosting scene
  17972. */
  17973. getScene(): Scene;
  17974. /**
  17975. * Does this action manager handles actions of any of the given triggers
  17976. * @param triggers defines the triggers to be tested
  17977. * @return a boolean indicating whether one (or more) of the triggers is handled
  17978. */
  17979. hasSpecificTriggers(triggers: number[]): boolean;
  17980. /**
  17981. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17982. * speed.
  17983. * @param triggerA defines the trigger to be tested
  17984. * @param triggerB defines the trigger to be tested
  17985. * @return a boolean indicating whether one (or more) of the triggers is handled
  17986. */
  17987. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17988. /**
  17989. * Does this action manager handles actions of a given trigger
  17990. * @param trigger defines the trigger to be tested
  17991. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17992. * @return whether the trigger is handled
  17993. */
  17994. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17995. /**
  17996. * Does this action manager has pointer triggers
  17997. */
  17998. get hasPointerTriggers(): boolean;
  17999. /**
  18000. * Does this action manager has pick triggers
  18001. */
  18002. get hasPickTriggers(): boolean;
  18003. /**
  18004. * Registers an action to this action manager
  18005. * @param action defines the action to be registered
  18006. * @return the action amended (prepared) after registration
  18007. */
  18008. registerAction(action: IAction): Nullable<IAction>;
  18009. /**
  18010. * Unregisters an action to this action manager
  18011. * @param action defines the action to be unregistered
  18012. * @return a boolean indicating whether the action has been unregistered
  18013. */
  18014. unregisterAction(action: IAction): Boolean;
  18015. /**
  18016. * Process a specific trigger
  18017. * @param trigger defines the trigger to process
  18018. * @param evt defines the event details to be processed
  18019. */
  18020. processTrigger(trigger: number, evt?: IActionEvent): void;
  18021. /** @hidden */
  18022. _getEffectiveTarget(target: any, propertyPath: string): any;
  18023. /** @hidden */
  18024. _getProperty(propertyPath: string): string;
  18025. /**
  18026. * Serialize this manager to a JSON object
  18027. * @param name defines the property name to store this manager
  18028. * @returns a JSON representation of this manager
  18029. */
  18030. serialize(name: string): any;
  18031. /**
  18032. * Creates a new ActionManager from a JSON data
  18033. * @param parsedActions defines the JSON data to read from
  18034. * @param object defines the hosting mesh
  18035. * @param scene defines the hosting scene
  18036. */
  18037. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18038. /**
  18039. * Get a trigger name by index
  18040. * @param trigger defines the trigger index
  18041. * @returns a trigger name
  18042. */
  18043. static GetTriggerName(trigger: number): string;
  18044. }
  18045. }
  18046. declare module BABYLON {
  18047. /**
  18048. * Class used to represent a sprite
  18049. * @see http://doc.babylonjs.com/babylon101/sprites
  18050. */
  18051. export class Sprite {
  18052. /** defines the name */
  18053. name: string;
  18054. /** Gets or sets the current world position */
  18055. position: Vector3;
  18056. /** Gets or sets the main color */
  18057. color: Color4;
  18058. /** Gets or sets the width */
  18059. width: number;
  18060. /** Gets or sets the height */
  18061. height: number;
  18062. /** Gets or sets rotation angle */
  18063. angle: number;
  18064. /** Gets or sets the cell index in the sprite sheet */
  18065. cellIndex: number;
  18066. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18067. cellRef: string;
  18068. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18069. invertU: number;
  18070. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18071. invertV: number;
  18072. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18073. disposeWhenFinishedAnimating: boolean;
  18074. /** Gets the list of attached animations */
  18075. animations: Animation[];
  18076. /** Gets or sets a boolean indicating if the sprite can be picked */
  18077. isPickable: boolean;
  18078. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18079. useAlphaForPicking: boolean;
  18080. /** @hidden */
  18081. _xOffset: number;
  18082. /** @hidden */
  18083. _yOffset: number;
  18084. /** @hidden */
  18085. _xSize: number;
  18086. /** @hidden */
  18087. _ySize: number;
  18088. /**
  18089. * Gets or sets the associated action manager
  18090. */
  18091. actionManager: Nullable<ActionManager>;
  18092. private _animationStarted;
  18093. private _loopAnimation;
  18094. private _fromIndex;
  18095. private _toIndex;
  18096. private _delay;
  18097. private _direction;
  18098. private _manager;
  18099. private _time;
  18100. private _onAnimationEnd;
  18101. /**
  18102. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18103. */
  18104. isVisible: boolean;
  18105. /**
  18106. * Gets or sets the sprite size
  18107. */
  18108. get size(): number;
  18109. set size(value: number);
  18110. /**
  18111. * Creates a new Sprite
  18112. * @param name defines the name
  18113. * @param manager defines the manager
  18114. */
  18115. constructor(
  18116. /** defines the name */
  18117. name: string, manager: ISpriteManager);
  18118. /**
  18119. * Starts an animation
  18120. * @param from defines the initial key
  18121. * @param to defines the end key
  18122. * @param loop defines if the animation must loop
  18123. * @param delay defines the start delay (in ms)
  18124. * @param onAnimationEnd defines a callback to call when animation ends
  18125. */
  18126. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18127. /** Stops current animation (if any) */
  18128. stopAnimation(): void;
  18129. /** @hidden */
  18130. _animate(deltaTime: number): void;
  18131. /** Release associated resources */
  18132. dispose(): void;
  18133. }
  18134. }
  18135. declare module BABYLON {
  18136. /**
  18137. * Information about the result of picking within a scene
  18138. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18139. */
  18140. export class PickingInfo {
  18141. /** @hidden */
  18142. _pickingUnavailable: boolean;
  18143. /**
  18144. * If the pick collided with an object
  18145. */
  18146. hit: boolean;
  18147. /**
  18148. * Distance away where the pick collided
  18149. */
  18150. distance: number;
  18151. /**
  18152. * The location of pick collision
  18153. */
  18154. pickedPoint: Nullable<Vector3>;
  18155. /**
  18156. * The mesh corresponding the the pick collision
  18157. */
  18158. pickedMesh: Nullable<AbstractMesh>;
  18159. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18160. bu: number;
  18161. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18162. bv: number;
  18163. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18164. faceId: number;
  18165. /** Id of the the submesh that was picked */
  18166. subMeshId: number;
  18167. /** If a sprite was picked, this will be the sprite the pick collided with */
  18168. pickedSprite: Nullable<Sprite>;
  18169. /**
  18170. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18171. */
  18172. originMesh: Nullable<AbstractMesh>;
  18173. /**
  18174. * The ray that was used to perform the picking.
  18175. */
  18176. ray: Nullable<Ray>;
  18177. /**
  18178. * Gets the normal correspodning to the face the pick collided with
  18179. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18180. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18181. * @returns The normal correspodning to the face the pick collided with
  18182. */
  18183. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18184. /**
  18185. * Gets the texture coordinates of where the pick occured
  18186. * @returns the vector containing the coordnates of the texture
  18187. */
  18188. getTextureCoordinates(): Nullable<Vector2>;
  18189. }
  18190. }
  18191. declare module BABYLON {
  18192. /**
  18193. * Gather the list of pointer event types as constants.
  18194. */
  18195. export class PointerEventTypes {
  18196. /**
  18197. * 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.
  18198. */
  18199. static readonly POINTERDOWN: number;
  18200. /**
  18201. * The pointerup event is fired when a pointer is no longer active.
  18202. */
  18203. static readonly POINTERUP: number;
  18204. /**
  18205. * The pointermove event is fired when a pointer changes coordinates.
  18206. */
  18207. static readonly POINTERMOVE: number;
  18208. /**
  18209. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18210. */
  18211. static readonly POINTERWHEEL: number;
  18212. /**
  18213. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18214. */
  18215. static readonly POINTERPICK: number;
  18216. /**
  18217. * The pointertap event is fired when a the object has been touched and released without drag.
  18218. */
  18219. static readonly POINTERTAP: number;
  18220. /**
  18221. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18222. */
  18223. static readonly POINTERDOUBLETAP: number;
  18224. }
  18225. /**
  18226. * Base class of pointer info types.
  18227. */
  18228. export class PointerInfoBase {
  18229. /**
  18230. * Defines the type of event (PointerEventTypes)
  18231. */
  18232. type: number;
  18233. /**
  18234. * Defines the related dom event
  18235. */
  18236. event: PointerEvent | MouseWheelEvent;
  18237. /**
  18238. * Instantiates the base class of pointers info.
  18239. * @param type Defines the type of event (PointerEventTypes)
  18240. * @param event Defines the related dom event
  18241. */
  18242. constructor(
  18243. /**
  18244. * Defines the type of event (PointerEventTypes)
  18245. */
  18246. type: number,
  18247. /**
  18248. * Defines the related dom event
  18249. */
  18250. event: PointerEvent | MouseWheelEvent);
  18251. }
  18252. /**
  18253. * This class is used to store pointer related info for the onPrePointerObservable event.
  18254. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18255. */
  18256. export class PointerInfoPre extends PointerInfoBase {
  18257. /**
  18258. * Ray from a pointer if availible (eg. 6dof controller)
  18259. */
  18260. ray: Nullable<Ray>;
  18261. /**
  18262. * Defines the local position of the pointer on the canvas.
  18263. */
  18264. localPosition: Vector2;
  18265. /**
  18266. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18267. */
  18268. skipOnPointerObservable: boolean;
  18269. /**
  18270. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18271. * @param type Defines the type of event (PointerEventTypes)
  18272. * @param event Defines the related dom event
  18273. * @param localX Defines the local x coordinates of the pointer when the event occured
  18274. * @param localY Defines the local y coordinates of the pointer when the event occured
  18275. */
  18276. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18277. }
  18278. /**
  18279. * This type contains all the data related to a pointer event in Babylon.js.
  18280. * 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.
  18281. */
  18282. export class PointerInfo extends PointerInfoBase {
  18283. /**
  18284. * Defines the picking info associated to the info (if any)\
  18285. */
  18286. pickInfo: Nullable<PickingInfo>;
  18287. /**
  18288. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18289. * @param type Defines the type of event (PointerEventTypes)
  18290. * @param event Defines the related dom event
  18291. * @param pickInfo Defines the picking info associated to the info (if any)\
  18292. */
  18293. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18294. /**
  18295. * Defines the picking info associated to the info (if any)\
  18296. */
  18297. pickInfo: Nullable<PickingInfo>);
  18298. }
  18299. /**
  18300. * Data relating to a touch event on the screen.
  18301. */
  18302. export interface PointerTouch {
  18303. /**
  18304. * X coordinate of touch.
  18305. */
  18306. x: number;
  18307. /**
  18308. * Y coordinate of touch.
  18309. */
  18310. y: number;
  18311. /**
  18312. * Id of touch. Unique for each finger.
  18313. */
  18314. pointerId: number;
  18315. /**
  18316. * Event type passed from DOM.
  18317. */
  18318. type: any;
  18319. }
  18320. }
  18321. declare module BABYLON {
  18322. /**
  18323. * Manage the mouse inputs to control the movement of a free camera.
  18324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18325. */
  18326. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18327. /**
  18328. * Define if touch is enabled in the mouse input
  18329. */
  18330. touchEnabled: boolean;
  18331. /**
  18332. * Defines the camera the input is attached to.
  18333. */
  18334. camera: FreeCamera;
  18335. /**
  18336. * Defines the buttons associated with the input to handle camera move.
  18337. */
  18338. buttons: number[];
  18339. /**
  18340. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18341. */
  18342. angularSensibility: number;
  18343. private _pointerInput;
  18344. private _onMouseMove;
  18345. private _observer;
  18346. private previousPosition;
  18347. /**
  18348. * Observable for when a pointer move event occurs containing the move offset
  18349. */
  18350. onPointerMovedObservable: Observable<{
  18351. offsetX: number;
  18352. offsetY: number;
  18353. }>;
  18354. /**
  18355. * @hidden
  18356. * If the camera should be rotated automatically based on pointer movement
  18357. */
  18358. _allowCameraRotation: boolean;
  18359. /**
  18360. * Manage the mouse inputs to control the movement of a free camera.
  18361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18362. * @param touchEnabled Defines if touch is enabled or not
  18363. */
  18364. constructor(
  18365. /**
  18366. * Define if touch is enabled in the mouse input
  18367. */
  18368. touchEnabled?: boolean);
  18369. /**
  18370. * Attach the input controls to a specific dom element to get the input from.
  18371. * @param element Defines the element the controls should be listened from
  18372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18373. */
  18374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18375. /**
  18376. * Called on JS contextmenu event.
  18377. * Override this method to provide functionality.
  18378. */
  18379. protected onContextMenu(evt: PointerEvent): void;
  18380. /**
  18381. * Detach the current controls from the specified dom element.
  18382. * @param element Defines the element to stop listening the inputs from
  18383. */
  18384. detachControl(element: Nullable<HTMLElement>): void;
  18385. /**
  18386. * Gets the class name of the current intput.
  18387. * @returns the class name
  18388. */
  18389. getClassName(): string;
  18390. /**
  18391. * Get the friendly name associated with the input class.
  18392. * @returns the input friendly name
  18393. */
  18394. getSimpleName(): string;
  18395. }
  18396. }
  18397. declare module BABYLON {
  18398. /**
  18399. * Manage the touch inputs to control the movement of a free camera.
  18400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18401. */
  18402. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18403. /**
  18404. * Defines the camera the input is attached to.
  18405. */
  18406. camera: FreeCamera;
  18407. /**
  18408. * Defines the touch sensibility for rotation.
  18409. * The higher the faster.
  18410. */
  18411. touchAngularSensibility: number;
  18412. /**
  18413. * Defines the touch sensibility for move.
  18414. * The higher the faster.
  18415. */
  18416. touchMoveSensibility: number;
  18417. private _offsetX;
  18418. private _offsetY;
  18419. private _pointerPressed;
  18420. private _pointerInput;
  18421. private _observer;
  18422. private _onLostFocus;
  18423. /**
  18424. * Attach the input controls to a specific dom element to get the input from.
  18425. * @param element Defines the element the controls should be listened from
  18426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18427. */
  18428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18429. /**
  18430. * Detach the current controls from the specified dom element.
  18431. * @param element Defines the element to stop listening the inputs from
  18432. */
  18433. detachControl(element: Nullable<HTMLElement>): void;
  18434. /**
  18435. * Update the current camera state depending on the inputs that have been used this frame.
  18436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18437. */
  18438. checkInputs(): void;
  18439. /**
  18440. * Gets the class name of the current intput.
  18441. * @returns the class name
  18442. */
  18443. getClassName(): string;
  18444. /**
  18445. * Get the friendly name associated with the input class.
  18446. * @returns the input friendly name
  18447. */
  18448. getSimpleName(): string;
  18449. }
  18450. }
  18451. declare module BABYLON {
  18452. /**
  18453. * Default Inputs manager for the FreeCamera.
  18454. * It groups all the default supported inputs for ease of use.
  18455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18456. */
  18457. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18458. /**
  18459. * @hidden
  18460. */
  18461. _mouseInput: Nullable<FreeCameraMouseInput>;
  18462. /**
  18463. * Instantiates a new FreeCameraInputsManager.
  18464. * @param camera Defines the camera the inputs belong to
  18465. */
  18466. constructor(camera: FreeCamera);
  18467. /**
  18468. * Add keyboard input support to the input manager.
  18469. * @returns the current input manager
  18470. */
  18471. addKeyboard(): FreeCameraInputsManager;
  18472. /**
  18473. * Add mouse input support to the input manager.
  18474. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18475. * @returns the current input manager
  18476. */
  18477. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18478. /**
  18479. * Removes the mouse input support from the manager
  18480. * @returns the current input manager
  18481. */
  18482. removeMouse(): FreeCameraInputsManager;
  18483. /**
  18484. * Add touch input support to the input manager.
  18485. * @returns the current input manager
  18486. */
  18487. addTouch(): FreeCameraInputsManager;
  18488. /**
  18489. * Remove all attached input methods from a camera
  18490. */
  18491. clear(): void;
  18492. }
  18493. }
  18494. declare module BABYLON {
  18495. /**
  18496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18497. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18499. */
  18500. export class FreeCamera extends TargetCamera {
  18501. /**
  18502. * Define the collision ellipsoid of the camera.
  18503. * This is helpful to simulate a camera body like the player body around the camera
  18504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18505. */
  18506. ellipsoid: Vector3;
  18507. /**
  18508. * Define an offset for the position of the ellipsoid around the camera.
  18509. * This can be helpful to determine the center of the body near the gravity center of the body
  18510. * instead of its head.
  18511. */
  18512. ellipsoidOffset: Vector3;
  18513. /**
  18514. * Enable or disable collisions of the camera with the rest of the scene objects.
  18515. */
  18516. checkCollisions: boolean;
  18517. /**
  18518. * Enable or disable gravity on the camera.
  18519. */
  18520. applyGravity: boolean;
  18521. /**
  18522. * Define the input manager associated to the camera.
  18523. */
  18524. inputs: FreeCameraInputsManager;
  18525. /**
  18526. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18527. * Higher values reduce sensitivity.
  18528. */
  18529. get angularSensibility(): number;
  18530. /**
  18531. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18532. * Higher values reduce sensitivity.
  18533. */
  18534. set angularSensibility(value: number);
  18535. /**
  18536. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18537. */
  18538. get keysUp(): number[];
  18539. set keysUp(value: number[]);
  18540. /**
  18541. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18542. */
  18543. get keysUpward(): number[];
  18544. set keysUpward(value: number[]);
  18545. /**
  18546. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18547. */
  18548. get keysDown(): number[];
  18549. set keysDown(value: number[]);
  18550. /**
  18551. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18552. */
  18553. get keysDownward(): number[];
  18554. set keysDownward(value: number[]);
  18555. /**
  18556. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18557. */
  18558. get keysLeft(): number[];
  18559. set keysLeft(value: number[]);
  18560. /**
  18561. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18562. */
  18563. get keysRight(): number[];
  18564. set keysRight(value: number[]);
  18565. /**
  18566. * Event raised when the camera collide with a mesh in the scene.
  18567. */
  18568. onCollide: (collidedMesh: AbstractMesh) => void;
  18569. private _collider;
  18570. private _needMoveForGravity;
  18571. private _oldPosition;
  18572. private _diffPosition;
  18573. private _newPosition;
  18574. /** @hidden */
  18575. _localDirection: Vector3;
  18576. /** @hidden */
  18577. _transformedDirection: Vector3;
  18578. /**
  18579. * Instantiates a Free Camera.
  18580. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18581. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18582. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18583. * @param name Define the name of the camera in the scene
  18584. * @param position Define the start position of the camera in the scene
  18585. * @param scene Define the scene the camera belongs to
  18586. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18587. */
  18588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18589. /**
  18590. * Attached controls to the current camera.
  18591. * @param element Defines the element the controls should be listened from
  18592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18593. */
  18594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18595. /**
  18596. * Detach the current controls from the camera.
  18597. * The camera will stop reacting to inputs.
  18598. * @param element Defines the element to stop listening the inputs from
  18599. */
  18600. detachControl(element: HTMLElement): void;
  18601. private _collisionMask;
  18602. /**
  18603. * Define a collision mask to limit the list of object the camera can collide with
  18604. */
  18605. get collisionMask(): number;
  18606. set collisionMask(mask: number);
  18607. /** @hidden */
  18608. _collideWithWorld(displacement: Vector3): void;
  18609. private _onCollisionPositionChange;
  18610. /** @hidden */
  18611. _checkInputs(): void;
  18612. /** @hidden */
  18613. _decideIfNeedsToMove(): boolean;
  18614. /** @hidden */
  18615. _updatePosition(): void;
  18616. /**
  18617. * Destroy the camera and release the current resources hold by it.
  18618. */
  18619. dispose(): void;
  18620. /**
  18621. * Gets the current object class name.
  18622. * @return the class name
  18623. */
  18624. getClassName(): string;
  18625. }
  18626. }
  18627. declare module BABYLON {
  18628. /**
  18629. * Represents a gamepad control stick position
  18630. */
  18631. export class StickValues {
  18632. /**
  18633. * The x component of the control stick
  18634. */
  18635. x: number;
  18636. /**
  18637. * The y component of the control stick
  18638. */
  18639. y: number;
  18640. /**
  18641. * Initializes the gamepad x and y control stick values
  18642. * @param x The x component of the gamepad control stick value
  18643. * @param y The y component of the gamepad control stick value
  18644. */
  18645. constructor(
  18646. /**
  18647. * The x component of the control stick
  18648. */
  18649. x: number,
  18650. /**
  18651. * The y component of the control stick
  18652. */
  18653. y: number);
  18654. }
  18655. /**
  18656. * An interface which manages callbacks for gamepad button changes
  18657. */
  18658. export interface GamepadButtonChanges {
  18659. /**
  18660. * Called when a gamepad has been changed
  18661. */
  18662. changed: boolean;
  18663. /**
  18664. * Called when a gamepad press event has been triggered
  18665. */
  18666. pressChanged: boolean;
  18667. /**
  18668. * Called when a touch event has been triggered
  18669. */
  18670. touchChanged: boolean;
  18671. /**
  18672. * Called when a value has changed
  18673. */
  18674. valueChanged: boolean;
  18675. }
  18676. /**
  18677. * Represents a gamepad
  18678. */
  18679. export class Gamepad {
  18680. /**
  18681. * The id of the gamepad
  18682. */
  18683. id: string;
  18684. /**
  18685. * The index of the gamepad
  18686. */
  18687. index: number;
  18688. /**
  18689. * The browser gamepad
  18690. */
  18691. browserGamepad: any;
  18692. /**
  18693. * Specifies what type of gamepad this represents
  18694. */
  18695. type: number;
  18696. private _leftStick;
  18697. private _rightStick;
  18698. /** @hidden */
  18699. _isConnected: boolean;
  18700. private _leftStickAxisX;
  18701. private _leftStickAxisY;
  18702. private _rightStickAxisX;
  18703. private _rightStickAxisY;
  18704. /**
  18705. * Triggered when the left control stick has been changed
  18706. */
  18707. private _onleftstickchanged;
  18708. /**
  18709. * Triggered when the right control stick has been changed
  18710. */
  18711. private _onrightstickchanged;
  18712. /**
  18713. * Represents a gamepad controller
  18714. */
  18715. static GAMEPAD: number;
  18716. /**
  18717. * Represents a generic controller
  18718. */
  18719. static GENERIC: number;
  18720. /**
  18721. * Represents an XBox controller
  18722. */
  18723. static XBOX: number;
  18724. /**
  18725. * Represents a pose-enabled controller
  18726. */
  18727. static POSE_ENABLED: number;
  18728. /**
  18729. * Represents an Dual Shock controller
  18730. */
  18731. static DUALSHOCK: number;
  18732. /**
  18733. * Specifies whether the left control stick should be Y-inverted
  18734. */
  18735. protected _invertLeftStickY: boolean;
  18736. /**
  18737. * Specifies if the gamepad has been connected
  18738. */
  18739. get isConnected(): boolean;
  18740. /**
  18741. * Initializes the gamepad
  18742. * @param id The id of the gamepad
  18743. * @param index The index of the gamepad
  18744. * @param browserGamepad The browser gamepad
  18745. * @param leftStickX The x component of the left joystick
  18746. * @param leftStickY The y component of the left joystick
  18747. * @param rightStickX The x component of the right joystick
  18748. * @param rightStickY The y component of the right joystick
  18749. */
  18750. constructor(
  18751. /**
  18752. * The id of the gamepad
  18753. */
  18754. id: string,
  18755. /**
  18756. * The index of the gamepad
  18757. */
  18758. index: number,
  18759. /**
  18760. * The browser gamepad
  18761. */
  18762. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18763. /**
  18764. * Callback triggered when the left joystick has changed
  18765. * @param callback
  18766. */
  18767. onleftstickchanged(callback: (values: StickValues) => void): void;
  18768. /**
  18769. * Callback triggered when the right joystick has changed
  18770. * @param callback
  18771. */
  18772. onrightstickchanged(callback: (values: StickValues) => void): void;
  18773. /**
  18774. * Gets the left joystick
  18775. */
  18776. get leftStick(): StickValues;
  18777. /**
  18778. * Sets the left joystick values
  18779. */
  18780. set leftStick(newValues: StickValues);
  18781. /**
  18782. * Gets the right joystick
  18783. */
  18784. get rightStick(): StickValues;
  18785. /**
  18786. * Sets the right joystick value
  18787. */
  18788. set rightStick(newValues: StickValues);
  18789. /**
  18790. * Updates the gamepad joystick positions
  18791. */
  18792. update(): void;
  18793. /**
  18794. * Disposes the gamepad
  18795. */
  18796. dispose(): void;
  18797. }
  18798. /**
  18799. * Represents a generic gamepad
  18800. */
  18801. export class GenericPad extends Gamepad {
  18802. private _buttons;
  18803. private _onbuttondown;
  18804. private _onbuttonup;
  18805. /**
  18806. * Observable triggered when a button has been pressed
  18807. */
  18808. onButtonDownObservable: Observable<number>;
  18809. /**
  18810. * Observable triggered when a button has been released
  18811. */
  18812. onButtonUpObservable: Observable<number>;
  18813. /**
  18814. * Callback triggered when a button has been pressed
  18815. * @param callback Called when a button has been pressed
  18816. */
  18817. onbuttondown(callback: (buttonPressed: number) => void): void;
  18818. /**
  18819. * Callback triggered when a button has been released
  18820. * @param callback Called when a button has been released
  18821. */
  18822. onbuttonup(callback: (buttonReleased: number) => void): void;
  18823. /**
  18824. * Initializes the generic gamepad
  18825. * @param id The id of the generic gamepad
  18826. * @param index The index of the generic gamepad
  18827. * @param browserGamepad The browser gamepad
  18828. */
  18829. constructor(id: string, index: number, browserGamepad: any);
  18830. private _setButtonValue;
  18831. /**
  18832. * Updates the generic gamepad
  18833. */
  18834. update(): void;
  18835. /**
  18836. * Disposes the generic gamepad
  18837. */
  18838. dispose(): void;
  18839. }
  18840. }
  18841. declare module BABYLON {
  18842. /**
  18843. * Defines the types of pose enabled controllers that are supported
  18844. */
  18845. export enum PoseEnabledControllerType {
  18846. /**
  18847. * HTC Vive
  18848. */
  18849. VIVE = 0,
  18850. /**
  18851. * Oculus Rift
  18852. */
  18853. OCULUS = 1,
  18854. /**
  18855. * Windows mixed reality
  18856. */
  18857. WINDOWS = 2,
  18858. /**
  18859. * Samsung gear VR
  18860. */
  18861. GEAR_VR = 3,
  18862. /**
  18863. * Google Daydream
  18864. */
  18865. DAYDREAM = 4,
  18866. /**
  18867. * Generic
  18868. */
  18869. GENERIC = 5
  18870. }
  18871. /**
  18872. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18873. */
  18874. export interface MutableGamepadButton {
  18875. /**
  18876. * Value of the button/trigger
  18877. */
  18878. value: number;
  18879. /**
  18880. * If the button/trigger is currently touched
  18881. */
  18882. touched: boolean;
  18883. /**
  18884. * If the button/trigger is currently pressed
  18885. */
  18886. pressed: boolean;
  18887. }
  18888. /**
  18889. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18890. * @hidden
  18891. */
  18892. export interface ExtendedGamepadButton extends GamepadButton {
  18893. /**
  18894. * If the button/trigger is currently pressed
  18895. */
  18896. readonly pressed: boolean;
  18897. /**
  18898. * If the button/trigger is currently touched
  18899. */
  18900. readonly touched: boolean;
  18901. /**
  18902. * Value of the button/trigger
  18903. */
  18904. readonly value: number;
  18905. }
  18906. /** @hidden */
  18907. export interface _GamePadFactory {
  18908. /**
  18909. * Returns whether or not the current gamepad can be created for this type of controller.
  18910. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18911. * @returns true if it can be created, otherwise false
  18912. */
  18913. canCreate(gamepadInfo: any): boolean;
  18914. /**
  18915. * Creates a new instance of the Gamepad.
  18916. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18917. * @returns the new gamepad instance
  18918. */
  18919. create(gamepadInfo: any): Gamepad;
  18920. }
  18921. /**
  18922. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18923. */
  18924. export class PoseEnabledControllerHelper {
  18925. /** @hidden */
  18926. static _ControllerFactories: _GamePadFactory[];
  18927. /** @hidden */
  18928. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18929. /**
  18930. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18931. * @param vrGamepad the gamepad to initialized
  18932. * @returns a vr controller of the type the gamepad identified as
  18933. */
  18934. static InitiateController(vrGamepad: any): Gamepad;
  18935. }
  18936. /**
  18937. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18938. */
  18939. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18940. /**
  18941. * If the controller is used in a webXR session
  18942. */
  18943. isXR: boolean;
  18944. private _deviceRoomPosition;
  18945. private _deviceRoomRotationQuaternion;
  18946. /**
  18947. * The device position in babylon space
  18948. */
  18949. devicePosition: Vector3;
  18950. /**
  18951. * The device rotation in babylon space
  18952. */
  18953. deviceRotationQuaternion: Quaternion;
  18954. /**
  18955. * The scale factor of the device in babylon space
  18956. */
  18957. deviceScaleFactor: number;
  18958. /**
  18959. * (Likely devicePosition should be used instead) The device position in its room space
  18960. */
  18961. position: Vector3;
  18962. /**
  18963. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18964. */
  18965. rotationQuaternion: Quaternion;
  18966. /**
  18967. * The type of controller (Eg. Windows mixed reality)
  18968. */
  18969. controllerType: PoseEnabledControllerType;
  18970. protected _calculatedPosition: Vector3;
  18971. private _calculatedRotation;
  18972. /**
  18973. * The raw pose from the device
  18974. */
  18975. rawPose: DevicePose;
  18976. private _trackPosition;
  18977. private _maxRotationDistFromHeadset;
  18978. private _draggedRoomRotation;
  18979. /**
  18980. * @hidden
  18981. */
  18982. _disableTrackPosition(fixedPosition: Vector3): void;
  18983. /**
  18984. * Internal, the mesh attached to the controller
  18985. * @hidden
  18986. */
  18987. _mesh: Nullable<AbstractMesh>;
  18988. private _poseControlledCamera;
  18989. private _leftHandSystemQuaternion;
  18990. /**
  18991. * Internal, matrix used to convert room space to babylon space
  18992. * @hidden
  18993. */
  18994. _deviceToWorld: Matrix;
  18995. /**
  18996. * Node to be used when casting a ray from the controller
  18997. * @hidden
  18998. */
  18999. _pointingPoseNode: Nullable<TransformNode>;
  19000. /**
  19001. * Name of the child mesh that can be used to cast a ray from the controller
  19002. */
  19003. static readonly POINTING_POSE: string;
  19004. /**
  19005. * Creates a new PoseEnabledController from a gamepad
  19006. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19007. */
  19008. constructor(browserGamepad: any);
  19009. private _workingMatrix;
  19010. /**
  19011. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19012. */
  19013. update(): void;
  19014. /**
  19015. * Updates only the pose device and mesh without doing any button event checking
  19016. */
  19017. protected _updatePoseAndMesh(): void;
  19018. /**
  19019. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19020. * @param poseData raw pose fromthe device
  19021. */
  19022. updateFromDevice(poseData: DevicePose): void;
  19023. /**
  19024. * @hidden
  19025. */
  19026. _meshAttachedObservable: Observable<AbstractMesh>;
  19027. /**
  19028. * Attaches a mesh to the controller
  19029. * @param mesh the mesh to be attached
  19030. */
  19031. attachToMesh(mesh: AbstractMesh): void;
  19032. /**
  19033. * Attaches the controllers mesh to a camera
  19034. * @param camera the camera the mesh should be attached to
  19035. */
  19036. attachToPoseControlledCamera(camera: TargetCamera): void;
  19037. /**
  19038. * Disposes of the controller
  19039. */
  19040. dispose(): void;
  19041. /**
  19042. * The mesh that is attached to the controller
  19043. */
  19044. get mesh(): Nullable<AbstractMesh>;
  19045. /**
  19046. * Gets the ray of the controller in the direction the controller is pointing
  19047. * @param length the length the resulting ray should be
  19048. * @returns a ray in the direction the controller is pointing
  19049. */
  19050. getForwardRay(length?: number): Ray;
  19051. }
  19052. }
  19053. declare module BABYLON {
  19054. /**
  19055. * Defines the WebVRController object that represents controllers tracked in 3D space
  19056. */
  19057. export abstract class WebVRController extends PoseEnabledController {
  19058. /**
  19059. * Internal, the default controller model for the controller
  19060. */
  19061. protected _defaultModel: Nullable<AbstractMesh>;
  19062. /**
  19063. * Fired when the trigger state has changed
  19064. */
  19065. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19066. /**
  19067. * Fired when the main button state has changed
  19068. */
  19069. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19070. /**
  19071. * Fired when the secondary button state has changed
  19072. */
  19073. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19074. /**
  19075. * Fired when the pad state has changed
  19076. */
  19077. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19078. /**
  19079. * Fired when controllers stick values have changed
  19080. */
  19081. onPadValuesChangedObservable: Observable<StickValues>;
  19082. /**
  19083. * Array of button availible on the controller
  19084. */
  19085. protected _buttons: Array<MutableGamepadButton>;
  19086. private _onButtonStateChange;
  19087. /**
  19088. * Fired when a controller button's state has changed
  19089. * @param callback the callback containing the button that was modified
  19090. */
  19091. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19092. /**
  19093. * X and Y axis corresponding to the controllers joystick
  19094. */
  19095. pad: StickValues;
  19096. /**
  19097. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19098. */
  19099. hand: string;
  19100. /**
  19101. * The default controller model for the controller
  19102. */
  19103. get defaultModel(): Nullable<AbstractMesh>;
  19104. /**
  19105. * Creates a new WebVRController from a gamepad
  19106. * @param vrGamepad the gamepad that the WebVRController should be created from
  19107. */
  19108. constructor(vrGamepad: any);
  19109. /**
  19110. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19111. */
  19112. update(): void;
  19113. /**
  19114. * Function to be called when a button is modified
  19115. */
  19116. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19117. /**
  19118. * Loads a mesh and attaches it to the controller
  19119. * @param scene the scene the mesh should be added to
  19120. * @param meshLoaded callback for when the mesh has been loaded
  19121. */
  19122. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19123. private _setButtonValue;
  19124. private _changes;
  19125. private _checkChanges;
  19126. /**
  19127. * Disposes of th webVRCOntroller
  19128. */
  19129. dispose(): void;
  19130. }
  19131. }
  19132. declare module BABYLON {
  19133. /**
  19134. * The HemisphericLight simulates the ambient environment light,
  19135. * so the passed direction is the light reflection direction, not the incoming direction.
  19136. */
  19137. export class HemisphericLight extends Light {
  19138. /**
  19139. * The groundColor is the light in the opposite direction to the one specified during creation.
  19140. * 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.
  19141. */
  19142. groundColor: Color3;
  19143. /**
  19144. * The light reflection direction, not the incoming direction.
  19145. */
  19146. direction: Vector3;
  19147. /**
  19148. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19149. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19150. * The HemisphericLight can't cast shadows.
  19151. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19152. * @param name The friendly name of the light
  19153. * @param direction The direction of the light reflection
  19154. * @param scene The scene the light belongs to
  19155. */
  19156. constructor(name: string, direction: Vector3, scene: Scene);
  19157. protected _buildUniformLayout(): void;
  19158. /**
  19159. * Returns the string "HemisphericLight".
  19160. * @return The class name
  19161. */
  19162. getClassName(): string;
  19163. /**
  19164. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19165. * Returns the updated direction.
  19166. * @param target The target the direction should point to
  19167. * @return The computed direction
  19168. */
  19169. setDirectionToTarget(target: Vector3): Vector3;
  19170. /**
  19171. * Returns the shadow generator associated to the light.
  19172. * @returns Always null for hemispheric lights because it does not support shadows.
  19173. */
  19174. getShadowGenerator(): Nullable<IShadowGenerator>;
  19175. /**
  19176. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19177. * @param effect The effect to update
  19178. * @param lightIndex The index of the light in the effect to update
  19179. * @returns The hemispheric light
  19180. */
  19181. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19182. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19183. /**
  19184. * Computes the world matrix of the node
  19185. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19186. * @param useWasUpdatedFlag defines a reserved property
  19187. * @returns the world matrix
  19188. */
  19189. computeWorldMatrix(): Matrix;
  19190. /**
  19191. * Returns the integer 3.
  19192. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19193. */
  19194. getTypeID(): number;
  19195. /**
  19196. * Prepares the list of defines specific to the light type.
  19197. * @param defines the list of defines
  19198. * @param lightIndex defines the index of the light for the effect
  19199. */
  19200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. /** @hidden */
  19205. export var vrMultiviewToSingleviewPixelShader: {
  19206. name: string;
  19207. shader: string;
  19208. };
  19209. }
  19210. declare module BABYLON {
  19211. /**
  19212. * Renders to multiple views with a single draw call
  19213. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19214. */
  19215. export class MultiviewRenderTarget extends RenderTargetTexture {
  19216. /**
  19217. * Creates a multiview render target
  19218. * @param scene scene used with the render target
  19219. * @param size the size of the render target (used for each view)
  19220. */
  19221. constructor(scene: Scene, size?: number | {
  19222. width: number;
  19223. height: number;
  19224. } | {
  19225. ratio: number;
  19226. });
  19227. /**
  19228. * @hidden
  19229. * @param faceIndex the face index, if its a cube texture
  19230. */
  19231. _bindFrameBuffer(faceIndex?: number): void;
  19232. /**
  19233. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19234. * @returns the view count
  19235. */
  19236. getViewCount(): number;
  19237. }
  19238. }
  19239. declare module BABYLON {
  19240. /**
  19241. * Represents a camera frustum
  19242. */
  19243. export class Frustum {
  19244. /**
  19245. * Gets the planes representing the frustum
  19246. * @param transform matrix to be applied to the returned planes
  19247. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19248. */
  19249. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19250. /**
  19251. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19256. /**
  19257. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19262. /**
  19263. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19268. /**
  19269. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19274. /**
  19275. * Gets the top frustum plane transformed by the transform matrix
  19276. * @param transform transformation matrix to be applied to the resulting frustum plane
  19277. * @param frustumPlane the resuling frustum plane
  19278. */
  19279. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19280. /**
  19281. * Gets the bottom frustum plane transformed by the transform matrix
  19282. * @param transform transformation matrix to be applied to the resulting frustum plane
  19283. * @param frustumPlane the resuling frustum plane
  19284. */
  19285. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19286. /**
  19287. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19288. * @param transform transformation matrix to be applied to the resulting frustum planes
  19289. * @param frustumPlanes the resuling frustum planes
  19290. */
  19291. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19292. }
  19293. }
  19294. declare module BABYLON {
  19295. interface Engine {
  19296. /**
  19297. * Creates a new multiview render target
  19298. * @param width defines the width of the texture
  19299. * @param height defines the height of the texture
  19300. * @returns the created multiview texture
  19301. */
  19302. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19303. /**
  19304. * Binds a multiview framebuffer to be drawn to
  19305. * @param multiviewTexture texture to bind
  19306. */
  19307. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19308. }
  19309. interface Camera {
  19310. /**
  19311. * @hidden
  19312. * 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)
  19313. */
  19314. _useMultiviewToSingleView: boolean;
  19315. /**
  19316. * @hidden
  19317. * 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)
  19318. */
  19319. _multiviewTexture: Nullable<RenderTargetTexture>;
  19320. /**
  19321. * @hidden
  19322. * ensures the multiview texture of the camera exists and has the specified width/height
  19323. * @param width height to set on the multiview texture
  19324. * @param height width to set on the multiview texture
  19325. */
  19326. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19327. }
  19328. interface Scene {
  19329. /** @hidden */
  19330. _transformMatrixR: Matrix;
  19331. /** @hidden */
  19332. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19333. /** @hidden */
  19334. _createMultiviewUbo(): void;
  19335. /** @hidden */
  19336. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19337. /** @hidden */
  19338. _renderMultiviewToSingleView(camera: Camera): void;
  19339. }
  19340. }
  19341. declare module BABYLON {
  19342. /**
  19343. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19344. * This will not be used for webXR as it supports displaying texture arrays directly
  19345. */
  19346. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19347. /**
  19348. * Initializes a VRMultiviewToSingleview
  19349. * @param name name of the post process
  19350. * @param camera camera to be applied to
  19351. * @param scaleFactor scaling factor to the size of the output texture
  19352. */
  19353. constructor(name: string, camera: Camera, scaleFactor: number);
  19354. }
  19355. }
  19356. declare module BABYLON {
  19357. /**
  19358. * Interface used to define additional presentation attributes
  19359. */
  19360. export interface IVRPresentationAttributes {
  19361. /**
  19362. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19363. */
  19364. highRefreshRate: boolean;
  19365. /**
  19366. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19367. */
  19368. foveationLevel: number;
  19369. }
  19370. interface Engine {
  19371. /** @hidden */
  19372. _vrDisplay: any;
  19373. /** @hidden */
  19374. _vrSupported: boolean;
  19375. /** @hidden */
  19376. _oldSize: Size;
  19377. /** @hidden */
  19378. _oldHardwareScaleFactor: number;
  19379. /** @hidden */
  19380. _vrExclusivePointerMode: boolean;
  19381. /** @hidden */
  19382. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19383. /** @hidden */
  19384. _onVRDisplayPointerRestricted: () => void;
  19385. /** @hidden */
  19386. _onVRDisplayPointerUnrestricted: () => void;
  19387. /** @hidden */
  19388. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19389. /** @hidden */
  19390. _onVrDisplayDisconnect: Nullable<() => void>;
  19391. /** @hidden */
  19392. _onVrDisplayPresentChange: Nullable<() => void>;
  19393. /**
  19394. * Observable signaled when VR display mode changes
  19395. */
  19396. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19397. /**
  19398. * Observable signaled when VR request present is complete
  19399. */
  19400. onVRRequestPresentComplete: Observable<boolean>;
  19401. /**
  19402. * Observable signaled when VR request present starts
  19403. */
  19404. onVRRequestPresentStart: Observable<Engine>;
  19405. /**
  19406. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19407. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19408. */
  19409. isInVRExclusivePointerMode: boolean;
  19410. /**
  19411. * Gets a boolean indicating if a webVR device was detected
  19412. * @returns true if a webVR device was detected
  19413. */
  19414. isVRDevicePresent(): boolean;
  19415. /**
  19416. * Gets the current webVR device
  19417. * @returns the current webVR device (or null)
  19418. */
  19419. getVRDevice(): any;
  19420. /**
  19421. * Initializes a webVR display and starts listening to display change events
  19422. * The onVRDisplayChangedObservable will be notified upon these changes
  19423. * @returns A promise containing a VRDisplay and if vr is supported
  19424. */
  19425. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19426. /** @hidden */
  19427. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19428. /**
  19429. * Gets or sets the presentation attributes used to configure VR rendering
  19430. */
  19431. vrPresentationAttributes?: IVRPresentationAttributes;
  19432. /**
  19433. * Call this function to switch to webVR mode
  19434. * Will do nothing if webVR is not supported or if there is no webVR device
  19435. * @param options the webvr options provided to the camera. mainly used for multiview
  19436. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19437. */
  19438. enableVR(options: WebVROptions): void;
  19439. /** @hidden */
  19440. _onVRFullScreenTriggered(): void;
  19441. }
  19442. }
  19443. declare module BABYLON {
  19444. /**
  19445. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19446. * IMPORTANT!! The data is right-hand data.
  19447. * @export
  19448. * @interface DevicePose
  19449. */
  19450. export interface DevicePose {
  19451. /**
  19452. * The position of the device, values in array are [x,y,z].
  19453. */
  19454. readonly position: Nullable<Float32Array>;
  19455. /**
  19456. * The linearVelocity of the device, values in array are [x,y,z].
  19457. */
  19458. readonly linearVelocity: Nullable<Float32Array>;
  19459. /**
  19460. * The linearAcceleration of the device, values in array are [x,y,z].
  19461. */
  19462. readonly linearAcceleration: Nullable<Float32Array>;
  19463. /**
  19464. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19465. */
  19466. readonly orientation: Nullable<Float32Array>;
  19467. /**
  19468. * The angularVelocity of the device, values in array are [x,y,z].
  19469. */
  19470. readonly angularVelocity: Nullable<Float32Array>;
  19471. /**
  19472. * The angularAcceleration of the device, values in array are [x,y,z].
  19473. */
  19474. readonly angularAcceleration: Nullable<Float32Array>;
  19475. }
  19476. /**
  19477. * Interface representing a pose controlled object in Babylon.
  19478. * A pose controlled object has both regular pose values as well as pose values
  19479. * from an external device such as a VR head mounted display
  19480. */
  19481. export interface PoseControlled {
  19482. /**
  19483. * The position of the object in babylon space.
  19484. */
  19485. position: Vector3;
  19486. /**
  19487. * The rotation quaternion of the object in babylon space.
  19488. */
  19489. rotationQuaternion: Quaternion;
  19490. /**
  19491. * The position of the device in babylon space.
  19492. */
  19493. devicePosition?: Vector3;
  19494. /**
  19495. * The rotation quaternion of the device in babylon space.
  19496. */
  19497. deviceRotationQuaternion: Quaternion;
  19498. /**
  19499. * The raw pose coming from the device.
  19500. */
  19501. rawPose: Nullable<DevicePose>;
  19502. /**
  19503. * The scale of the device to be used when translating from device space to babylon space.
  19504. */
  19505. deviceScaleFactor: number;
  19506. /**
  19507. * Updates the poseControlled values based on the input device pose.
  19508. * @param poseData the pose data to update the object with
  19509. */
  19510. updateFromDevice(poseData: DevicePose): void;
  19511. }
  19512. /**
  19513. * Set of options to customize the webVRCamera
  19514. */
  19515. export interface WebVROptions {
  19516. /**
  19517. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19518. */
  19519. trackPosition?: boolean;
  19520. /**
  19521. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19522. */
  19523. positionScale?: number;
  19524. /**
  19525. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19526. */
  19527. displayName?: string;
  19528. /**
  19529. * Should the native controller meshes be initialized. (default: true)
  19530. */
  19531. controllerMeshes?: boolean;
  19532. /**
  19533. * Creating a default HemiLight only on controllers. (default: true)
  19534. */
  19535. defaultLightingOnControllers?: boolean;
  19536. /**
  19537. * If you don't want to use the default VR button of the helper. (default: false)
  19538. */
  19539. useCustomVRButton?: boolean;
  19540. /**
  19541. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19542. */
  19543. customVRButton?: HTMLButtonElement;
  19544. /**
  19545. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19546. */
  19547. rayLength?: number;
  19548. /**
  19549. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19550. */
  19551. defaultHeight?: number;
  19552. /**
  19553. * If multiview should be used if availible (default: false)
  19554. */
  19555. useMultiview?: boolean;
  19556. }
  19557. /**
  19558. * This represents a WebVR camera.
  19559. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19560. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19561. */
  19562. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19563. private webVROptions;
  19564. /**
  19565. * @hidden
  19566. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19567. */
  19568. _vrDevice: any;
  19569. /**
  19570. * The rawPose of the vrDevice.
  19571. */
  19572. rawPose: Nullable<DevicePose>;
  19573. private _onVREnabled;
  19574. private _specsVersion;
  19575. private _attached;
  19576. private _frameData;
  19577. protected _descendants: Array<Node>;
  19578. private _deviceRoomPosition;
  19579. /** @hidden */
  19580. _deviceRoomRotationQuaternion: Quaternion;
  19581. private _standingMatrix;
  19582. /**
  19583. * Represents device position in babylon space.
  19584. */
  19585. devicePosition: Vector3;
  19586. /**
  19587. * Represents device rotation in babylon space.
  19588. */
  19589. deviceRotationQuaternion: Quaternion;
  19590. /**
  19591. * The scale of the device to be used when translating from device space to babylon space.
  19592. */
  19593. deviceScaleFactor: number;
  19594. private _deviceToWorld;
  19595. private _worldToDevice;
  19596. /**
  19597. * References to the webVR controllers for the vrDevice.
  19598. */
  19599. controllers: Array<WebVRController>;
  19600. /**
  19601. * Emits an event when a controller is attached.
  19602. */
  19603. onControllersAttachedObservable: Observable<WebVRController[]>;
  19604. /**
  19605. * Emits an event when a controller's mesh has been loaded;
  19606. */
  19607. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19608. /**
  19609. * Emits an event when the HMD's pose has been updated.
  19610. */
  19611. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19612. private _poseSet;
  19613. /**
  19614. * If the rig cameras be used as parent instead of this camera.
  19615. */
  19616. rigParenting: boolean;
  19617. private _lightOnControllers;
  19618. private _defaultHeight?;
  19619. /**
  19620. * Instantiates a WebVRFreeCamera.
  19621. * @param name The name of the WebVRFreeCamera
  19622. * @param position The starting anchor position for the camera
  19623. * @param scene The scene the camera belongs to
  19624. * @param webVROptions a set of customizable options for the webVRCamera
  19625. */
  19626. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19627. /**
  19628. * Gets the device distance from the ground in meters.
  19629. * @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.
  19630. */
  19631. deviceDistanceToRoomGround(): number;
  19632. /**
  19633. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19634. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19635. */
  19636. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19637. /**
  19638. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19639. * @returns A promise with a boolean set to if the standing matrix is supported.
  19640. */
  19641. useStandingMatrixAsync(): Promise<boolean>;
  19642. /**
  19643. * Disposes the camera
  19644. */
  19645. dispose(): void;
  19646. /**
  19647. * Gets a vrController by name.
  19648. * @param name The name of the controller to retreive
  19649. * @returns the controller matching the name specified or null if not found
  19650. */
  19651. getControllerByName(name: string): Nullable<WebVRController>;
  19652. private _leftController;
  19653. /**
  19654. * The controller corresponding to the users left hand.
  19655. */
  19656. get leftController(): Nullable<WebVRController>;
  19657. private _rightController;
  19658. /**
  19659. * The controller corresponding to the users right hand.
  19660. */
  19661. get rightController(): Nullable<WebVRController>;
  19662. /**
  19663. * Casts a ray forward from the vrCamera's gaze.
  19664. * @param length Length of the ray (default: 100)
  19665. * @returns the ray corresponding to the gaze
  19666. */
  19667. getForwardRay(length?: number): Ray;
  19668. /**
  19669. * @hidden
  19670. * Updates the camera based on device's frame data
  19671. */
  19672. _checkInputs(): void;
  19673. /**
  19674. * Updates the poseControlled values based on the input device pose.
  19675. * @param poseData Pose coming from the device
  19676. */
  19677. updateFromDevice(poseData: DevicePose): void;
  19678. private _htmlElementAttached;
  19679. private _detachIfAttached;
  19680. /**
  19681. * WebVR's attach control will start broadcasting frames to the device.
  19682. * Note that in certain browsers (chrome for example) this function must be called
  19683. * within a user-interaction callback. Example:
  19684. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19685. *
  19686. * @param element html element to attach the vrDevice to
  19687. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19688. */
  19689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19690. /**
  19691. * Detaches the camera from the html element and disables VR
  19692. *
  19693. * @param element html element to detach from
  19694. */
  19695. detachControl(element: HTMLElement): void;
  19696. /**
  19697. * @returns the name of this class
  19698. */
  19699. getClassName(): string;
  19700. /**
  19701. * Calls resetPose on the vrDisplay
  19702. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19703. */
  19704. resetToCurrentRotation(): void;
  19705. /**
  19706. * @hidden
  19707. * Updates the rig cameras (left and right eye)
  19708. */
  19709. _updateRigCameras(): void;
  19710. private _workingVector;
  19711. private _oneVector;
  19712. private _workingMatrix;
  19713. private updateCacheCalled;
  19714. private _correctPositionIfNotTrackPosition;
  19715. /**
  19716. * @hidden
  19717. * Updates the cached values of the camera
  19718. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19719. */
  19720. _updateCache(ignoreParentClass?: boolean): void;
  19721. /**
  19722. * @hidden
  19723. * Get current device position in babylon world
  19724. */
  19725. _computeDevicePosition(): void;
  19726. /**
  19727. * Updates the current device position and rotation in the babylon world
  19728. */
  19729. update(): void;
  19730. /**
  19731. * @hidden
  19732. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19733. * @returns an identity matrix
  19734. */
  19735. _getViewMatrix(): Matrix;
  19736. private _tmpMatrix;
  19737. /**
  19738. * This function is called by the two RIG cameras.
  19739. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19740. * @hidden
  19741. */
  19742. _getWebVRViewMatrix(): Matrix;
  19743. /** @hidden */
  19744. _getWebVRProjectionMatrix(): Matrix;
  19745. private _onGamepadConnectedObserver;
  19746. private _onGamepadDisconnectedObserver;
  19747. private _updateCacheWhenTrackingDisabledObserver;
  19748. /**
  19749. * Initializes the controllers and their meshes
  19750. */
  19751. initControllers(): void;
  19752. }
  19753. }
  19754. declare module BABYLON {
  19755. /**
  19756. * Size options for a post process
  19757. */
  19758. export type PostProcessOptions = {
  19759. width: number;
  19760. height: number;
  19761. };
  19762. /**
  19763. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19764. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19765. */
  19766. export class PostProcess {
  19767. /** Name of the PostProcess. */
  19768. name: string;
  19769. /**
  19770. * Gets or sets the unique id of the post process
  19771. */
  19772. uniqueId: number;
  19773. /**
  19774. * Width of the texture to apply the post process on
  19775. */
  19776. width: number;
  19777. /**
  19778. * Height of the texture to apply the post process on
  19779. */
  19780. height: number;
  19781. /**
  19782. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19783. * @hidden
  19784. */
  19785. _outputTexture: Nullable<InternalTexture>;
  19786. /**
  19787. * Sampling mode used by the shader
  19788. * See https://doc.babylonjs.com/classes/3.1/texture
  19789. */
  19790. renderTargetSamplingMode: number;
  19791. /**
  19792. * Clear color to use when screen clearing
  19793. */
  19794. clearColor: Color4;
  19795. /**
  19796. * If the buffer needs to be cleared before applying the post process. (default: true)
  19797. * Should be set to false if shader will overwrite all previous pixels.
  19798. */
  19799. autoClear: boolean;
  19800. /**
  19801. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19802. */
  19803. alphaMode: number;
  19804. /**
  19805. * Sets the setAlphaBlendConstants of the babylon engine
  19806. */
  19807. alphaConstants: Color4;
  19808. /**
  19809. * Animations to be used for the post processing
  19810. */
  19811. animations: Animation[];
  19812. /**
  19813. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19814. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19815. */
  19816. enablePixelPerfectMode: boolean;
  19817. /**
  19818. * Force the postprocess to be applied without taking in account viewport
  19819. */
  19820. forceFullscreenViewport: boolean;
  19821. /**
  19822. * List of inspectable custom properties (used by the Inspector)
  19823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19824. */
  19825. inspectableCustomProperties: IInspectable[];
  19826. /**
  19827. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19828. *
  19829. * | Value | Type | Description |
  19830. * | ----- | ----------------------------------- | ----------- |
  19831. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19832. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19833. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19834. *
  19835. */
  19836. scaleMode: number;
  19837. /**
  19838. * Force textures to be a power of two (default: false)
  19839. */
  19840. alwaysForcePOT: boolean;
  19841. private _samples;
  19842. /**
  19843. * Number of sample textures (default: 1)
  19844. */
  19845. get samples(): number;
  19846. set samples(n: number);
  19847. /**
  19848. * Modify the scale of the post process to be the same as the viewport (default: false)
  19849. */
  19850. adaptScaleToCurrentViewport: boolean;
  19851. private _camera;
  19852. private _scene;
  19853. private _engine;
  19854. private _options;
  19855. private _reusable;
  19856. private _textureType;
  19857. private _textureFormat;
  19858. /**
  19859. * Smart array of input and output textures for the post process.
  19860. * @hidden
  19861. */
  19862. _textures: SmartArray<InternalTexture>;
  19863. /**
  19864. * The index in _textures that corresponds to the output texture.
  19865. * @hidden
  19866. */
  19867. _currentRenderTextureInd: number;
  19868. private _effect;
  19869. private _samplers;
  19870. private _fragmentUrl;
  19871. private _vertexUrl;
  19872. private _parameters;
  19873. private _scaleRatio;
  19874. protected _indexParameters: any;
  19875. private _shareOutputWithPostProcess;
  19876. private _texelSize;
  19877. private _forcedOutputTexture;
  19878. /**
  19879. * Returns the fragment url or shader name used in the post process.
  19880. * @returns the fragment url or name in the shader store.
  19881. */
  19882. getEffectName(): string;
  19883. /**
  19884. * An event triggered when the postprocess is activated.
  19885. */
  19886. onActivateObservable: Observable<Camera>;
  19887. private _onActivateObserver;
  19888. /**
  19889. * A function that is added to the onActivateObservable
  19890. */
  19891. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19892. /**
  19893. * An event triggered when the postprocess changes its size.
  19894. */
  19895. onSizeChangedObservable: Observable<PostProcess>;
  19896. private _onSizeChangedObserver;
  19897. /**
  19898. * A function that is added to the onSizeChangedObservable
  19899. */
  19900. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19901. /**
  19902. * An event triggered when the postprocess applies its effect.
  19903. */
  19904. onApplyObservable: Observable<Effect>;
  19905. private _onApplyObserver;
  19906. /**
  19907. * A function that is added to the onApplyObservable
  19908. */
  19909. set onApply(callback: (effect: Effect) => void);
  19910. /**
  19911. * An event triggered before rendering the postprocess
  19912. */
  19913. onBeforeRenderObservable: Observable<Effect>;
  19914. private _onBeforeRenderObserver;
  19915. /**
  19916. * A function that is added to the onBeforeRenderObservable
  19917. */
  19918. set onBeforeRender(callback: (effect: Effect) => void);
  19919. /**
  19920. * An event triggered after rendering the postprocess
  19921. */
  19922. onAfterRenderObservable: Observable<Effect>;
  19923. private _onAfterRenderObserver;
  19924. /**
  19925. * A function that is added to the onAfterRenderObservable
  19926. */
  19927. set onAfterRender(callback: (efect: Effect) => void);
  19928. /**
  19929. * 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
  19930. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19931. */
  19932. get inputTexture(): InternalTexture;
  19933. set inputTexture(value: InternalTexture);
  19934. /**
  19935. * Gets the camera which post process is applied to.
  19936. * @returns The camera the post process is applied to.
  19937. */
  19938. getCamera(): Camera;
  19939. /**
  19940. * Gets the texel size of the postprocess.
  19941. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19942. */
  19943. get texelSize(): Vector2;
  19944. /**
  19945. * Creates a new instance PostProcess
  19946. * @param name The name of the PostProcess.
  19947. * @param fragmentUrl The url of the fragment shader to be used.
  19948. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19949. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19951. * @param camera The camera to apply the render pass to.
  19952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19953. * @param engine The engine which the post process will be applied. (default: current engine)
  19954. * @param reusable If the post process can be reused on the same frame. (default: false)
  19955. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19956. * @param textureType Type of textures used when performing the post process. (default: 0)
  19957. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19958. * @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
  19959. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19960. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19961. */
  19962. constructor(
  19963. /** Name of the PostProcess. */
  19964. 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);
  19965. /**
  19966. * Gets a string idenfifying the name of the class
  19967. * @returns "PostProcess" string
  19968. */
  19969. getClassName(): string;
  19970. /**
  19971. * Gets the engine which this post process belongs to.
  19972. * @returns The engine the post process was enabled with.
  19973. */
  19974. getEngine(): Engine;
  19975. /**
  19976. * The effect that is created when initializing the post process.
  19977. * @returns The created effect corresponding the the postprocess.
  19978. */
  19979. getEffect(): Effect;
  19980. /**
  19981. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19982. * @param postProcess The post process to share the output with.
  19983. * @returns This post process.
  19984. */
  19985. shareOutputWith(postProcess: PostProcess): PostProcess;
  19986. /**
  19987. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19988. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19989. */
  19990. useOwnOutput(): void;
  19991. /**
  19992. * Updates the effect with the current post process compile time values and recompiles the shader.
  19993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19996. * @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
  19997. * @param onCompiled Called when the shader has been compiled.
  19998. * @param onError Called if there is an error when compiling a shader.
  19999. */
  20000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20001. /**
  20002. * The post process is reusable if it can be used multiple times within one frame.
  20003. * @returns If the post process is reusable
  20004. */
  20005. isReusable(): boolean;
  20006. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20007. markTextureDirty(): void;
  20008. /**
  20009. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20010. * 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.
  20011. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20012. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20013. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20014. * @returns The target texture that was bound to be written to.
  20015. */
  20016. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20017. /**
  20018. * If the post process is supported.
  20019. */
  20020. get isSupported(): boolean;
  20021. /**
  20022. * The aspect ratio of the output texture.
  20023. */
  20024. get aspectRatio(): number;
  20025. /**
  20026. * Get a value indicating if the post-process is ready to be used
  20027. * @returns true if the post-process is ready (shader is compiled)
  20028. */
  20029. isReady(): boolean;
  20030. /**
  20031. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20032. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20033. */
  20034. apply(): Nullable<Effect>;
  20035. private _disposeTextures;
  20036. /**
  20037. * Disposes the post process.
  20038. * @param camera The camera to dispose the post process on.
  20039. */
  20040. dispose(camera?: Camera): void;
  20041. }
  20042. }
  20043. declare module BABYLON {
  20044. /** @hidden */
  20045. export var kernelBlurVaryingDeclaration: {
  20046. name: string;
  20047. shader: string;
  20048. };
  20049. }
  20050. declare module BABYLON {
  20051. /** @hidden */
  20052. export var kernelBlurFragment: {
  20053. name: string;
  20054. shader: string;
  20055. };
  20056. }
  20057. declare module BABYLON {
  20058. /** @hidden */
  20059. export var kernelBlurFragment2: {
  20060. name: string;
  20061. shader: string;
  20062. };
  20063. }
  20064. declare module BABYLON {
  20065. /** @hidden */
  20066. export var kernelBlurPixelShader: {
  20067. name: string;
  20068. shader: string;
  20069. };
  20070. }
  20071. declare module BABYLON {
  20072. /** @hidden */
  20073. export var kernelBlurVertex: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module BABYLON {
  20079. /** @hidden */
  20080. export var kernelBlurVertexShader: {
  20081. name: string;
  20082. shader: string;
  20083. };
  20084. }
  20085. declare module BABYLON {
  20086. /**
  20087. * The Blur Post Process which blurs an image based on a kernel and direction.
  20088. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20089. */
  20090. export class BlurPostProcess extends PostProcess {
  20091. /** The direction in which to blur the image. */
  20092. direction: Vector2;
  20093. private blockCompilation;
  20094. protected _kernel: number;
  20095. protected _idealKernel: number;
  20096. protected _packedFloat: boolean;
  20097. private _staticDefines;
  20098. /**
  20099. * Sets the length in pixels of the blur sample region
  20100. */
  20101. set kernel(v: number);
  20102. /**
  20103. * Gets the length in pixels of the blur sample region
  20104. */
  20105. get kernel(): number;
  20106. /**
  20107. * Sets wether or not the blur needs to unpack/repack floats
  20108. */
  20109. set packedFloat(v: boolean);
  20110. /**
  20111. * Gets wether or not the blur is unpacking/repacking floats
  20112. */
  20113. get packedFloat(): boolean;
  20114. /**
  20115. * Creates a new instance BlurPostProcess
  20116. * @param name The name of the effect.
  20117. * @param direction The direction in which to blur the image.
  20118. * @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.
  20119. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20120. * @param camera The camera to apply the render pass to.
  20121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20122. * @param engine The engine which the post process will be applied. (default: current engine)
  20123. * @param reusable If the post process can be reused on the same frame. (default: false)
  20124. * @param textureType Type of textures used when performing the post process. (default: 0)
  20125. * @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)
  20126. */
  20127. constructor(name: string,
  20128. /** The direction in which to blur the image. */
  20129. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20130. /**
  20131. * Updates the effect with the current post process compile time values and recompiles the shader.
  20132. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20133. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20134. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20135. * @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
  20136. * @param onCompiled Called when the shader has been compiled.
  20137. * @param onError Called if there is an error when compiling a shader.
  20138. */
  20139. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20140. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20141. /**
  20142. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20143. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20144. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20145. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20146. * The gaps between physical kernels are compensated for in the weighting of the samples
  20147. * @param idealKernel Ideal blur kernel.
  20148. * @return Nearest best kernel.
  20149. */
  20150. protected _nearestBestKernel(idealKernel: number): number;
  20151. /**
  20152. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20153. * @param x The point on the Gaussian distribution to sample.
  20154. * @return the value of the Gaussian function at x.
  20155. */
  20156. protected _gaussianWeight(x: number): number;
  20157. /**
  20158. * Generates a string that can be used as a floating point number in GLSL.
  20159. * @param x Value to print.
  20160. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20161. * @return GLSL float string.
  20162. */
  20163. protected _glslFloat(x: number, decimalFigures?: number): string;
  20164. }
  20165. }
  20166. declare module BABYLON {
  20167. /**
  20168. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20169. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20170. * You can then easily use it as a reflectionTexture on a flat surface.
  20171. * In case the surface is not a plane, please consider relying on reflection probes.
  20172. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20173. */
  20174. export class MirrorTexture extends RenderTargetTexture {
  20175. private scene;
  20176. /**
  20177. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20178. * 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.
  20179. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20180. */
  20181. mirrorPlane: Plane;
  20182. /**
  20183. * Define the blur ratio used to blur the reflection if needed.
  20184. */
  20185. set blurRatio(value: number);
  20186. get blurRatio(): number;
  20187. /**
  20188. * Define the adaptive blur kernel used to blur the reflection if needed.
  20189. * This will autocompute the closest best match for the `blurKernel`
  20190. */
  20191. set adaptiveBlurKernel(value: number);
  20192. /**
  20193. * Define the blur kernel used to blur the reflection if needed.
  20194. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20195. */
  20196. set blurKernel(value: number);
  20197. /**
  20198. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20199. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20200. */
  20201. set blurKernelX(value: number);
  20202. get blurKernelX(): number;
  20203. /**
  20204. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20205. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20206. */
  20207. set blurKernelY(value: number);
  20208. get blurKernelY(): number;
  20209. private _autoComputeBlurKernel;
  20210. protected _onRatioRescale(): void;
  20211. private _updateGammaSpace;
  20212. private _imageProcessingConfigChangeObserver;
  20213. private _transformMatrix;
  20214. private _mirrorMatrix;
  20215. private _savedViewMatrix;
  20216. private _blurX;
  20217. private _blurY;
  20218. private _adaptiveBlurKernel;
  20219. private _blurKernelX;
  20220. private _blurKernelY;
  20221. private _blurRatio;
  20222. /**
  20223. * Instantiates a Mirror Texture.
  20224. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20225. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20226. * You can then easily use it as a reflectionTexture on a flat surface.
  20227. * In case the surface is not a plane, please consider relying on reflection probes.
  20228. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20229. * @param name
  20230. * @param size
  20231. * @param scene
  20232. * @param generateMipMaps
  20233. * @param type
  20234. * @param samplingMode
  20235. * @param generateDepthBuffer
  20236. */
  20237. constructor(name: string, size: number | {
  20238. width: number;
  20239. height: number;
  20240. } | {
  20241. ratio: number;
  20242. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20243. private _preparePostProcesses;
  20244. /**
  20245. * Clone the mirror texture.
  20246. * @returns the cloned texture
  20247. */
  20248. clone(): MirrorTexture;
  20249. /**
  20250. * Serialize the texture to a JSON representation you could use in Parse later on
  20251. * @returns the serialized JSON representation
  20252. */
  20253. serialize(): any;
  20254. /**
  20255. * Dispose the texture and release its associated resources.
  20256. */
  20257. dispose(): void;
  20258. }
  20259. }
  20260. declare module BABYLON {
  20261. /**
  20262. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20263. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20264. */
  20265. export class Texture extends BaseTexture {
  20266. /**
  20267. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20268. */
  20269. static SerializeBuffers: boolean;
  20270. /** @hidden */
  20271. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20272. /** @hidden */
  20273. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20274. /** @hidden */
  20275. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20276. /** nearest is mag = nearest and min = nearest and mip = linear */
  20277. static readonly NEAREST_SAMPLINGMODE: number;
  20278. /** nearest is mag = nearest and min = nearest and mip = linear */
  20279. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20280. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20281. static readonly BILINEAR_SAMPLINGMODE: number;
  20282. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20283. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20284. /** Trilinear is mag = linear and min = linear and mip = linear */
  20285. static readonly TRILINEAR_SAMPLINGMODE: number;
  20286. /** Trilinear is mag = linear and min = linear and mip = linear */
  20287. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20288. /** mag = nearest and min = nearest and mip = nearest */
  20289. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20290. /** mag = nearest and min = linear and mip = nearest */
  20291. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20292. /** mag = nearest and min = linear and mip = linear */
  20293. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20294. /** mag = nearest and min = linear and mip = none */
  20295. static readonly NEAREST_LINEAR: number;
  20296. /** mag = nearest and min = nearest and mip = none */
  20297. static readonly NEAREST_NEAREST: number;
  20298. /** mag = linear and min = nearest and mip = nearest */
  20299. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20300. /** mag = linear and min = nearest and mip = linear */
  20301. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20302. /** mag = linear and min = linear and mip = none */
  20303. static readonly LINEAR_LINEAR: number;
  20304. /** mag = linear and min = nearest and mip = none */
  20305. static readonly LINEAR_NEAREST: number;
  20306. /** Explicit coordinates mode */
  20307. static readonly EXPLICIT_MODE: number;
  20308. /** Spherical coordinates mode */
  20309. static readonly SPHERICAL_MODE: number;
  20310. /** Planar coordinates mode */
  20311. static readonly PLANAR_MODE: number;
  20312. /** Cubic coordinates mode */
  20313. static readonly CUBIC_MODE: number;
  20314. /** Projection coordinates mode */
  20315. static readonly PROJECTION_MODE: number;
  20316. /** Inverse Cubic coordinates mode */
  20317. static readonly SKYBOX_MODE: number;
  20318. /** Inverse Cubic coordinates mode */
  20319. static readonly INVCUBIC_MODE: number;
  20320. /** Equirectangular coordinates mode */
  20321. static readonly EQUIRECTANGULAR_MODE: number;
  20322. /** Equirectangular Fixed coordinates mode */
  20323. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20324. /** Equirectangular Fixed Mirrored coordinates mode */
  20325. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20326. /** Texture is not repeating outside of 0..1 UVs */
  20327. static readonly CLAMP_ADDRESSMODE: number;
  20328. /** Texture is repeating outside of 0..1 UVs */
  20329. static readonly WRAP_ADDRESSMODE: number;
  20330. /** Texture is repeating and mirrored */
  20331. static readonly MIRROR_ADDRESSMODE: number;
  20332. /**
  20333. * 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
  20334. */
  20335. static UseSerializedUrlIfAny: boolean;
  20336. /**
  20337. * Define the url of the texture.
  20338. */
  20339. url: Nullable<string>;
  20340. /**
  20341. * Define an offset on the texture to offset the u coordinates of the UVs
  20342. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20343. */
  20344. uOffset: number;
  20345. /**
  20346. * Define an offset on the texture to offset the v coordinates of the UVs
  20347. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20348. */
  20349. vOffset: number;
  20350. /**
  20351. * Define an offset on the texture to scale the u coordinates of the UVs
  20352. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20353. */
  20354. uScale: number;
  20355. /**
  20356. * Define an offset on the texture to scale the v coordinates of the UVs
  20357. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20358. */
  20359. vScale: number;
  20360. /**
  20361. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20362. * @see http://doc.babylonjs.com/how_to/more_materials
  20363. */
  20364. uAng: number;
  20365. /**
  20366. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20367. * @see http://doc.babylonjs.com/how_to/more_materials
  20368. */
  20369. vAng: number;
  20370. /**
  20371. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20372. * @see http://doc.babylonjs.com/how_to/more_materials
  20373. */
  20374. wAng: number;
  20375. /**
  20376. * Defines the center of rotation (U)
  20377. */
  20378. uRotationCenter: number;
  20379. /**
  20380. * Defines the center of rotation (V)
  20381. */
  20382. vRotationCenter: number;
  20383. /**
  20384. * Defines the center of rotation (W)
  20385. */
  20386. wRotationCenter: number;
  20387. /**
  20388. * Are mip maps generated for this texture or not.
  20389. */
  20390. get noMipmap(): boolean;
  20391. /**
  20392. * List of inspectable custom properties (used by the Inspector)
  20393. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20394. */
  20395. inspectableCustomProperties: Nullable<IInspectable[]>;
  20396. private _noMipmap;
  20397. /** @hidden */
  20398. _invertY: boolean;
  20399. private _rowGenerationMatrix;
  20400. private _cachedTextureMatrix;
  20401. private _projectionModeMatrix;
  20402. private _t0;
  20403. private _t1;
  20404. private _t2;
  20405. private _cachedUOffset;
  20406. private _cachedVOffset;
  20407. private _cachedUScale;
  20408. private _cachedVScale;
  20409. private _cachedUAng;
  20410. private _cachedVAng;
  20411. private _cachedWAng;
  20412. private _cachedProjectionMatrixId;
  20413. private _cachedCoordinatesMode;
  20414. /** @hidden */
  20415. protected _initialSamplingMode: number;
  20416. /** @hidden */
  20417. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20418. private _deleteBuffer;
  20419. protected _format: Nullable<number>;
  20420. private _delayedOnLoad;
  20421. private _delayedOnError;
  20422. private _mimeType?;
  20423. /**
  20424. * Observable triggered once the texture has been loaded.
  20425. */
  20426. onLoadObservable: Observable<Texture>;
  20427. protected _isBlocking: boolean;
  20428. /**
  20429. * Is the texture preventing material to render while loading.
  20430. * If false, a default texture will be used instead of the loading one during the preparation step.
  20431. */
  20432. set isBlocking(value: boolean);
  20433. get isBlocking(): boolean;
  20434. /**
  20435. * Get the current sampling mode associated with the texture.
  20436. */
  20437. get samplingMode(): number;
  20438. /**
  20439. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20440. */
  20441. get invertY(): boolean;
  20442. /**
  20443. * Instantiates a new texture.
  20444. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20445. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20446. * @param url defines the url of the picture to load as a texture
  20447. * @param scene defines the scene or engine the texture will belong to
  20448. * @param noMipmap defines if the texture will require mip maps or not
  20449. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20450. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20451. * @param onLoad defines a callback triggered when the texture has been loaded
  20452. * @param onError defines a callback triggered when an error occurred during the loading session
  20453. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20454. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20455. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20456. * @param mimeType defines an optional mime type information
  20457. */
  20458. 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);
  20459. /**
  20460. * Update the url (and optional buffer) of this texture if url was null during construction.
  20461. * @param url the url of the texture
  20462. * @param buffer the buffer of the texture (defaults to null)
  20463. * @param onLoad callback called when the texture is loaded (defaults to null)
  20464. */
  20465. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20466. /**
  20467. * Finish the loading sequence of a texture flagged as delayed load.
  20468. * @hidden
  20469. */
  20470. delayLoad(): void;
  20471. private _prepareRowForTextureGeneration;
  20472. /**
  20473. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20474. * @returns the transform matrix of the texture.
  20475. */
  20476. getTextureMatrix(uBase?: number): Matrix;
  20477. /**
  20478. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20479. * @returns The reflection texture transform
  20480. */
  20481. getReflectionTextureMatrix(): Matrix;
  20482. /**
  20483. * Clones the texture.
  20484. * @returns the cloned texture
  20485. */
  20486. clone(): Texture;
  20487. /**
  20488. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20489. * @returns The JSON representation of the texture
  20490. */
  20491. serialize(): any;
  20492. /**
  20493. * Get the current class name of the texture useful for serialization or dynamic coding.
  20494. * @returns "Texture"
  20495. */
  20496. getClassName(): string;
  20497. /**
  20498. * Dispose the texture and release its associated resources.
  20499. */
  20500. dispose(): void;
  20501. /**
  20502. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20503. * @param parsedTexture Define the JSON representation of the texture
  20504. * @param scene Define the scene the parsed texture should be instantiated in
  20505. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20506. * @returns The parsed texture if successful
  20507. */
  20508. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20509. /**
  20510. * Creates a texture from its base 64 representation.
  20511. * @param data Define the base64 payload without the data: prefix
  20512. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20513. * @param scene Define the scene the texture should belong to
  20514. * @param noMipmap Forces the texture to not create mip map information if true
  20515. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20516. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20517. * @param onLoad define a callback triggered when the texture has been loaded
  20518. * @param onError define a callback triggered when an error occurred during the loading session
  20519. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20520. * @returns the created texture
  20521. */
  20522. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20523. /**
  20524. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20525. * @param data Define the base64 payload without the data: prefix
  20526. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20527. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20528. * @param scene Define the scene the texture should belong to
  20529. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20530. * @param noMipmap Forces the texture to not create mip map information if true
  20531. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20532. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20533. * @param onLoad define a callback triggered when the texture has been loaded
  20534. * @param onError define a callback triggered when an error occurred during the loading session
  20535. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20536. * @returns the created texture
  20537. */
  20538. 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;
  20539. }
  20540. }
  20541. declare module BABYLON {
  20542. /**
  20543. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20544. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20545. */
  20546. export class PostProcessManager {
  20547. private _scene;
  20548. private _indexBuffer;
  20549. private _vertexBuffers;
  20550. /**
  20551. * Creates a new instance PostProcess
  20552. * @param scene The scene that the post process is associated with.
  20553. */
  20554. constructor(scene: Scene);
  20555. private _prepareBuffers;
  20556. private _buildIndexBuffer;
  20557. /**
  20558. * Rebuilds the vertex buffers of the manager.
  20559. * @hidden
  20560. */
  20561. _rebuild(): void;
  20562. /**
  20563. * Prepares a frame to be run through a post process.
  20564. * @param sourceTexture The input texture to the post procesess. (default: null)
  20565. * @param postProcesses An array of post processes to be run. (default: null)
  20566. * @returns True if the post processes were able to be run.
  20567. * @hidden
  20568. */
  20569. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20570. /**
  20571. * Manually render a set of post processes to a texture.
  20572. * @param postProcesses An array of post processes to be run.
  20573. * @param targetTexture The target texture to render to.
  20574. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20575. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20576. * @param lodLevel defines which lod of the texture to render to
  20577. */
  20578. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20579. /**
  20580. * Finalize the result of the output of the postprocesses.
  20581. * @param doNotPresent If true the result will not be displayed to the screen.
  20582. * @param targetTexture The target texture to render to.
  20583. * @param faceIndex The index of the face to bind the target texture to.
  20584. * @param postProcesses The array of post processes to render.
  20585. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20586. * @hidden
  20587. */
  20588. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20589. /**
  20590. * Disposes of the post process manager.
  20591. */
  20592. dispose(): void;
  20593. }
  20594. }
  20595. declare module BABYLON {
  20596. /**
  20597. * This Helps creating a texture that will be created from a camera in your scene.
  20598. * It is basically a dynamic texture that could be used to create special effects for instance.
  20599. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20600. */
  20601. export class RenderTargetTexture extends Texture {
  20602. isCube: boolean;
  20603. /**
  20604. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20605. */
  20606. static readonly REFRESHRATE_RENDER_ONCE: number;
  20607. /**
  20608. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20609. */
  20610. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20611. /**
  20612. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20613. * the central point of your effect and can save a lot of performances.
  20614. */
  20615. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20616. /**
  20617. * Use this predicate to dynamically define the list of mesh you want to render.
  20618. * If set, the renderList property will be overwritten.
  20619. */
  20620. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20621. private _renderList;
  20622. /**
  20623. * Use this list to define the list of mesh you want to render.
  20624. */
  20625. get renderList(): Nullable<Array<AbstractMesh>>;
  20626. set renderList(value: Nullable<Array<AbstractMesh>>);
  20627. /**
  20628. * Use this function to overload the renderList array at rendering time.
  20629. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20630. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20631. * the cube (if the RTT is a cube, else layerOrFace=0).
  20632. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20633. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20634. * hold dummy elements!
  20635. */
  20636. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20637. private _hookArray;
  20638. /**
  20639. * Define if particles should be rendered in your texture.
  20640. */
  20641. renderParticles: boolean;
  20642. /**
  20643. * Define if sprites should be rendered in your texture.
  20644. */
  20645. renderSprites: boolean;
  20646. /**
  20647. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20648. */
  20649. coordinatesMode: number;
  20650. /**
  20651. * Define the camera used to render the texture.
  20652. */
  20653. activeCamera: Nullable<Camera>;
  20654. /**
  20655. * Override the mesh isReady function with your own one.
  20656. */
  20657. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20658. /**
  20659. * Override the render function of the texture with your own one.
  20660. */
  20661. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20662. /**
  20663. * Define if camera post processes should be use while rendering the texture.
  20664. */
  20665. useCameraPostProcesses: boolean;
  20666. /**
  20667. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20668. */
  20669. ignoreCameraViewport: boolean;
  20670. private _postProcessManager;
  20671. private _postProcesses;
  20672. private _resizeObserver;
  20673. /**
  20674. * An event triggered when the texture is unbind.
  20675. */
  20676. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20677. /**
  20678. * An event triggered when the texture is unbind.
  20679. */
  20680. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20681. private _onAfterUnbindObserver;
  20682. /**
  20683. * Set a after unbind callback in the texture.
  20684. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20685. */
  20686. set onAfterUnbind(callback: () => void);
  20687. /**
  20688. * An event triggered before rendering the texture
  20689. */
  20690. onBeforeRenderObservable: Observable<number>;
  20691. private _onBeforeRenderObserver;
  20692. /**
  20693. * Set a before render callback in the texture.
  20694. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20695. */
  20696. set onBeforeRender(callback: (faceIndex: number) => void);
  20697. /**
  20698. * An event triggered after rendering the texture
  20699. */
  20700. onAfterRenderObservable: Observable<number>;
  20701. private _onAfterRenderObserver;
  20702. /**
  20703. * Set a after render callback in the texture.
  20704. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20705. */
  20706. set onAfterRender(callback: (faceIndex: number) => void);
  20707. /**
  20708. * An event triggered after the texture clear
  20709. */
  20710. onClearObservable: Observable<Engine>;
  20711. private _onClearObserver;
  20712. /**
  20713. * Set a clear callback in the texture.
  20714. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20715. */
  20716. set onClear(callback: (Engine: Engine) => void);
  20717. /**
  20718. * An event triggered when the texture is resized.
  20719. */
  20720. onResizeObservable: Observable<RenderTargetTexture>;
  20721. /**
  20722. * Define the clear color of the Render Target if it should be different from the scene.
  20723. */
  20724. clearColor: Color4;
  20725. protected _size: number | {
  20726. width: number;
  20727. height: number;
  20728. layers?: number;
  20729. };
  20730. protected _initialSizeParameter: number | {
  20731. width: number;
  20732. height: number;
  20733. } | {
  20734. ratio: number;
  20735. };
  20736. protected _sizeRatio: Nullable<number>;
  20737. /** @hidden */
  20738. _generateMipMaps: boolean;
  20739. protected _renderingManager: RenderingManager;
  20740. /** @hidden */
  20741. _waitingRenderList: string[];
  20742. protected _doNotChangeAspectRatio: boolean;
  20743. protected _currentRefreshId: number;
  20744. protected _refreshRate: number;
  20745. protected _textureMatrix: Matrix;
  20746. protected _samples: number;
  20747. protected _renderTargetOptions: RenderTargetCreationOptions;
  20748. /**
  20749. * Gets render target creation options that were used.
  20750. */
  20751. get renderTargetOptions(): RenderTargetCreationOptions;
  20752. protected _engine: Engine;
  20753. protected _onRatioRescale(): void;
  20754. /**
  20755. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20756. * It must define where the camera used to render the texture is set
  20757. */
  20758. boundingBoxPosition: Vector3;
  20759. private _boundingBoxSize;
  20760. /**
  20761. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20762. * When defined, the cubemap will switch to local mode
  20763. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20764. * @example https://www.babylonjs-playground.com/#RNASML
  20765. */
  20766. set boundingBoxSize(value: Vector3);
  20767. get boundingBoxSize(): Vector3;
  20768. /**
  20769. * In case the RTT has been created with a depth texture, get the associated
  20770. * depth texture.
  20771. * Otherwise, return null.
  20772. */
  20773. get depthStencilTexture(): Nullable<InternalTexture>;
  20774. /**
  20775. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20776. * or used a shadow, depth texture...
  20777. * @param name The friendly name of the texture
  20778. * @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)
  20779. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20780. * @param generateMipMaps True if mip maps need to be generated after render.
  20781. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20782. * @param type The type of the buffer in the RTT (int, half float, float...)
  20783. * @param isCube True if a cube texture needs to be created
  20784. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20785. * @param generateDepthBuffer True to generate a depth buffer
  20786. * @param generateStencilBuffer True to generate a stencil buffer
  20787. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20788. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20789. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20790. */
  20791. constructor(name: string, size: number | {
  20792. width: number;
  20793. height: number;
  20794. layers?: number;
  20795. } | {
  20796. ratio: number;
  20797. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20798. /**
  20799. * Creates a depth stencil texture.
  20800. * This is only available in WebGL 2 or with the depth texture extension available.
  20801. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20802. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20803. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20804. */
  20805. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20806. private _processSizeParameter;
  20807. /**
  20808. * Define the number of samples to use in case of MSAA.
  20809. * It defaults to one meaning no MSAA has been enabled.
  20810. */
  20811. get samples(): number;
  20812. set samples(value: number);
  20813. /**
  20814. * Resets the refresh counter of the texture and start bak from scratch.
  20815. * Could be useful to regenerate the texture if it is setup to render only once.
  20816. */
  20817. resetRefreshCounter(): void;
  20818. /**
  20819. * Define the refresh rate of the texture or the rendering frequency.
  20820. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20821. */
  20822. get refreshRate(): number;
  20823. set refreshRate(value: number);
  20824. /**
  20825. * Adds a post process to the render target rendering passes.
  20826. * @param postProcess define the post process to add
  20827. */
  20828. addPostProcess(postProcess: PostProcess): void;
  20829. /**
  20830. * Clear all the post processes attached to the render target
  20831. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20832. */
  20833. clearPostProcesses(dispose?: boolean): void;
  20834. /**
  20835. * Remove one of the post process from the list of attached post processes to the texture
  20836. * @param postProcess define the post process to remove from the list
  20837. */
  20838. removePostProcess(postProcess: PostProcess): void;
  20839. /** @hidden */
  20840. _shouldRender(): boolean;
  20841. /**
  20842. * Gets the actual render size of the texture.
  20843. * @returns the width of the render size
  20844. */
  20845. getRenderSize(): number;
  20846. /**
  20847. * Gets the actual render width of the texture.
  20848. * @returns the width of the render size
  20849. */
  20850. getRenderWidth(): number;
  20851. /**
  20852. * Gets the actual render height of the texture.
  20853. * @returns the height of the render size
  20854. */
  20855. getRenderHeight(): number;
  20856. /**
  20857. * Gets the actual number of layers of the texture.
  20858. * @returns the number of layers
  20859. */
  20860. getRenderLayers(): number;
  20861. /**
  20862. * Get if the texture can be rescaled or not.
  20863. */
  20864. get canRescale(): boolean;
  20865. /**
  20866. * Resize the texture using a ratio.
  20867. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20868. */
  20869. scale(ratio: number): void;
  20870. /**
  20871. * Get the texture reflection matrix used to rotate/transform the reflection.
  20872. * @returns the reflection matrix
  20873. */
  20874. getReflectionTextureMatrix(): Matrix;
  20875. /**
  20876. * Resize the texture to a new desired size.
  20877. * Be carrefull as it will recreate all the data in the new texture.
  20878. * @param size Define the new size. It can be:
  20879. * - a number for squared texture,
  20880. * - an object containing { width: number, height: number }
  20881. * - or an object containing a ratio { ratio: number }
  20882. */
  20883. resize(size: number | {
  20884. width: number;
  20885. height: number;
  20886. } | {
  20887. ratio: number;
  20888. }): void;
  20889. private _defaultRenderListPrepared;
  20890. /**
  20891. * Renders all the objects from the render list into the texture.
  20892. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20893. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20894. */
  20895. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20896. private _bestReflectionRenderTargetDimension;
  20897. private _prepareRenderingManager;
  20898. /**
  20899. * @hidden
  20900. * @param faceIndex face index to bind to if this is a cubetexture
  20901. * @param layer defines the index of the texture to bind in the array
  20902. */
  20903. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20904. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20905. private renderToTarget;
  20906. /**
  20907. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20908. * This allowed control for front to back rendering or reversly depending of the special needs.
  20909. *
  20910. * @param renderingGroupId The rendering group id corresponding to its index
  20911. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20912. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20913. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20914. */
  20915. 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;
  20916. /**
  20917. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20918. *
  20919. * @param renderingGroupId The rendering group id corresponding to its index
  20920. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20921. */
  20922. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20923. /**
  20924. * Clones the texture.
  20925. * @returns the cloned texture
  20926. */
  20927. clone(): RenderTargetTexture;
  20928. /**
  20929. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20930. * @returns The JSON representation of the texture
  20931. */
  20932. serialize(): any;
  20933. /**
  20934. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20935. */
  20936. disposeFramebufferObjects(): void;
  20937. /**
  20938. * Dispose the texture and release its associated resources.
  20939. */
  20940. dispose(): void;
  20941. /** @hidden */
  20942. _rebuild(): void;
  20943. /**
  20944. * Clear the info related to rendering groups preventing retention point in material dispose.
  20945. */
  20946. freeRenderingGroups(): void;
  20947. /**
  20948. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20949. * @returns the view count
  20950. */
  20951. getViewCount(): number;
  20952. }
  20953. }
  20954. declare module BABYLON {
  20955. /**
  20956. * Options for compiling materials.
  20957. */
  20958. export interface IMaterialCompilationOptions {
  20959. /**
  20960. * Defines whether clip planes are enabled.
  20961. */
  20962. clipPlane: boolean;
  20963. /**
  20964. * Defines whether instances are enabled.
  20965. */
  20966. useInstances: boolean;
  20967. }
  20968. /**
  20969. * Base class for the main features of a material in Babylon.js
  20970. */
  20971. export class Material implements IAnimatable {
  20972. /**
  20973. * Returns the triangle fill mode
  20974. */
  20975. static readonly TriangleFillMode: number;
  20976. /**
  20977. * Returns the wireframe mode
  20978. */
  20979. static readonly WireFrameFillMode: number;
  20980. /**
  20981. * Returns the point fill mode
  20982. */
  20983. static readonly PointFillMode: number;
  20984. /**
  20985. * Returns the point list draw mode
  20986. */
  20987. static readonly PointListDrawMode: number;
  20988. /**
  20989. * Returns the line list draw mode
  20990. */
  20991. static readonly LineListDrawMode: number;
  20992. /**
  20993. * Returns the line loop draw mode
  20994. */
  20995. static readonly LineLoopDrawMode: number;
  20996. /**
  20997. * Returns the line strip draw mode
  20998. */
  20999. static readonly LineStripDrawMode: number;
  21000. /**
  21001. * Returns the triangle strip draw mode
  21002. */
  21003. static readonly TriangleStripDrawMode: number;
  21004. /**
  21005. * Returns the triangle fan draw mode
  21006. */
  21007. static readonly TriangleFanDrawMode: number;
  21008. /**
  21009. * Stores the clock-wise side orientation
  21010. */
  21011. static readonly ClockWiseSideOrientation: number;
  21012. /**
  21013. * Stores the counter clock-wise side orientation
  21014. */
  21015. static readonly CounterClockWiseSideOrientation: number;
  21016. /**
  21017. * The dirty texture flag value
  21018. */
  21019. static readonly TextureDirtyFlag: number;
  21020. /**
  21021. * The dirty light flag value
  21022. */
  21023. static readonly LightDirtyFlag: number;
  21024. /**
  21025. * The dirty fresnel flag value
  21026. */
  21027. static readonly FresnelDirtyFlag: number;
  21028. /**
  21029. * The dirty attribute flag value
  21030. */
  21031. static readonly AttributesDirtyFlag: number;
  21032. /**
  21033. * The dirty misc flag value
  21034. */
  21035. static readonly MiscDirtyFlag: number;
  21036. /**
  21037. * The all dirty flag value
  21038. */
  21039. static readonly AllDirtyFlag: number;
  21040. /**
  21041. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21042. */
  21043. static readonly MATERIAL_OPAQUE: number;
  21044. /**
  21045. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21046. */
  21047. static readonly MATERIAL_ALPHATEST: number;
  21048. /**
  21049. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21050. */
  21051. static readonly MATERIAL_ALPHABLEND: number;
  21052. /**
  21053. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21054. * They are also discarded below the alpha cutoff threshold to improve performances.
  21055. */
  21056. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21057. /**
  21058. * The ID of the material
  21059. */
  21060. id: string;
  21061. /**
  21062. * Gets or sets the unique id of the material
  21063. */
  21064. uniqueId: number;
  21065. /**
  21066. * The name of the material
  21067. */
  21068. name: string;
  21069. /**
  21070. * Gets or sets user defined metadata
  21071. */
  21072. metadata: any;
  21073. /**
  21074. * For internal use only. Please do not use.
  21075. */
  21076. reservedDataStore: any;
  21077. /**
  21078. * Specifies if the ready state should be checked on each call
  21079. */
  21080. checkReadyOnEveryCall: boolean;
  21081. /**
  21082. * Specifies if the ready state should be checked once
  21083. */
  21084. checkReadyOnlyOnce: boolean;
  21085. /**
  21086. * The state of the material
  21087. */
  21088. state: string;
  21089. /**
  21090. * The alpha value of the material
  21091. */
  21092. protected _alpha: number;
  21093. /**
  21094. * List of inspectable custom properties (used by the Inspector)
  21095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21096. */
  21097. inspectableCustomProperties: IInspectable[];
  21098. /**
  21099. * Sets the alpha value of the material
  21100. */
  21101. set alpha(value: number);
  21102. /**
  21103. * Gets the alpha value of the material
  21104. */
  21105. get alpha(): number;
  21106. /**
  21107. * Specifies if back face culling is enabled
  21108. */
  21109. protected _backFaceCulling: boolean;
  21110. /**
  21111. * Sets the back-face culling state
  21112. */
  21113. set backFaceCulling(value: boolean);
  21114. /**
  21115. * Gets the back-face culling state
  21116. */
  21117. get backFaceCulling(): boolean;
  21118. /**
  21119. * Stores the value for side orientation
  21120. */
  21121. sideOrientation: number;
  21122. /**
  21123. * Callback triggered when the material is compiled
  21124. */
  21125. onCompiled: Nullable<(effect: Effect) => void>;
  21126. /**
  21127. * Callback triggered when an error occurs
  21128. */
  21129. onError: Nullable<(effect: Effect, errors: string) => void>;
  21130. /**
  21131. * Callback triggered to get the render target textures
  21132. */
  21133. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21134. /**
  21135. * Gets a boolean indicating that current material needs to register RTT
  21136. */
  21137. get hasRenderTargetTextures(): boolean;
  21138. /**
  21139. * Specifies if the material should be serialized
  21140. */
  21141. doNotSerialize: boolean;
  21142. /**
  21143. * @hidden
  21144. */
  21145. _storeEffectOnSubMeshes: boolean;
  21146. /**
  21147. * Stores the animations for the material
  21148. */
  21149. animations: Nullable<Array<Animation>>;
  21150. /**
  21151. * An event triggered when the material is disposed
  21152. */
  21153. onDisposeObservable: Observable<Material>;
  21154. /**
  21155. * An observer which watches for dispose events
  21156. */
  21157. private _onDisposeObserver;
  21158. private _onUnBindObservable;
  21159. /**
  21160. * Called during a dispose event
  21161. */
  21162. set onDispose(callback: () => void);
  21163. private _onBindObservable;
  21164. /**
  21165. * An event triggered when the material is bound
  21166. */
  21167. get onBindObservable(): Observable<AbstractMesh>;
  21168. /**
  21169. * An observer which watches for bind events
  21170. */
  21171. private _onBindObserver;
  21172. /**
  21173. * Called during a bind event
  21174. */
  21175. set onBind(callback: (Mesh: AbstractMesh) => void);
  21176. /**
  21177. * An event triggered when the material is unbound
  21178. */
  21179. get onUnBindObservable(): Observable<Material>;
  21180. /**
  21181. * Stores the value of the alpha mode
  21182. */
  21183. private _alphaMode;
  21184. /**
  21185. * Sets the value of the alpha mode.
  21186. *
  21187. * | Value | Type | Description |
  21188. * | --- | --- | --- |
  21189. * | 0 | ALPHA_DISABLE | |
  21190. * | 1 | ALPHA_ADD | |
  21191. * | 2 | ALPHA_COMBINE | |
  21192. * | 3 | ALPHA_SUBTRACT | |
  21193. * | 4 | ALPHA_MULTIPLY | |
  21194. * | 5 | ALPHA_MAXIMIZED | |
  21195. * | 6 | ALPHA_ONEONE | |
  21196. * | 7 | ALPHA_PREMULTIPLIED | |
  21197. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21198. * | 9 | ALPHA_INTERPOLATE | |
  21199. * | 10 | ALPHA_SCREENMODE | |
  21200. *
  21201. */
  21202. set alphaMode(value: number);
  21203. /**
  21204. * Gets the value of the alpha mode
  21205. */
  21206. get alphaMode(): number;
  21207. /**
  21208. * Stores the state of the need depth pre-pass value
  21209. */
  21210. private _needDepthPrePass;
  21211. /**
  21212. * Sets the need depth pre-pass value
  21213. */
  21214. set needDepthPrePass(value: boolean);
  21215. /**
  21216. * Gets the depth pre-pass value
  21217. */
  21218. get needDepthPrePass(): boolean;
  21219. /**
  21220. * Specifies if depth writing should be disabled
  21221. */
  21222. disableDepthWrite: boolean;
  21223. /**
  21224. * Specifies if depth writing should be forced
  21225. */
  21226. forceDepthWrite: boolean;
  21227. /**
  21228. * Specifies the depth function that should be used. 0 means the default engine function
  21229. */
  21230. depthFunction: number;
  21231. /**
  21232. * Specifies if there should be a separate pass for culling
  21233. */
  21234. separateCullingPass: boolean;
  21235. /**
  21236. * Stores the state specifing if fog should be enabled
  21237. */
  21238. private _fogEnabled;
  21239. /**
  21240. * Sets the state for enabling fog
  21241. */
  21242. set fogEnabled(value: boolean);
  21243. /**
  21244. * Gets the value of the fog enabled state
  21245. */
  21246. get fogEnabled(): boolean;
  21247. /**
  21248. * Stores the size of points
  21249. */
  21250. pointSize: number;
  21251. /**
  21252. * Stores the z offset value
  21253. */
  21254. zOffset: number;
  21255. /**
  21256. * Gets a value specifying if wireframe mode is enabled
  21257. */
  21258. get wireframe(): boolean;
  21259. /**
  21260. * Sets the state of wireframe mode
  21261. */
  21262. set wireframe(value: boolean);
  21263. /**
  21264. * Gets the value specifying if point clouds are enabled
  21265. */
  21266. get pointsCloud(): boolean;
  21267. /**
  21268. * Sets the state of point cloud mode
  21269. */
  21270. set pointsCloud(value: boolean);
  21271. /**
  21272. * Gets the material fill mode
  21273. */
  21274. get fillMode(): number;
  21275. /**
  21276. * Sets the material fill mode
  21277. */
  21278. set fillMode(value: number);
  21279. /**
  21280. * @hidden
  21281. * Stores the effects for the material
  21282. */
  21283. _effect: Nullable<Effect>;
  21284. /**
  21285. * Specifies if uniform buffers should be used
  21286. */
  21287. private _useUBO;
  21288. /**
  21289. * Stores a reference to the scene
  21290. */
  21291. private _scene;
  21292. /**
  21293. * Stores the fill mode state
  21294. */
  21295. private _fillMode;
  21296. /**
  21297. * Specifies if the depth write state should be cached
  21298. */
  21299. private _cachedDepthWriteState;
  21300. /**
  21301. * Specifies if the depth function state should be cached
  21302. */
  21303. private _cachedDepthFunctionState;
  21304. /**
  21305. * Stores the uniform buffer
  21306. */
  21307. protected _uniformBuffer: UniformBuffer;
  21308. /** @hidden */
  21309. _indexInSceneMaterialArray: number;
  21310. /** @hidden */
  21311. meshMap: Nullable<{
  21312. [id: string]: AbstractMesh | undefined;
  21313. }>;
  21314. /**
  21315. * Creates a material instance
  21316. * @param name defines the name of the material
  21317. * @param scene defines the scene to reference
  21318. * @param doNotAdd specifies if the material should be added to the scene
  21319. */
  21320. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21321. /**
  21322. * Returns a string representation of the current material
  21323. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21324. * @returns a string with material information
  21325. */
  21326. toString(fullDetails?: boolean): string;
  21327. /**
  21328. * Gets the class name of the material
  21329. * @returns a string with the class name of the material
  21330. */
  21331. getClassName(): string;
  21332. /**
  21333. * Specifies if updates for the material been locked
  21334. */
  21335. get isFrozen(): boolean;
  21336. /**
  21337. * Locks updates for the material
  21338. */
  21339. freeze(): void;
  21340. /**
  21341. * Unlocks updates for the material
  21342. */
  21343. unfreeze(): void;
  21344. /**
  21345. * Specifies if the material is ready to be used
  21346. * @param mesh defines the mesh to check
  21347. * @param useInstances specifies if instances should be used
  21348. * @returns a boolean indicating if the material is ready to be used
  21349. */
  21350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21351. /**
  21352. * Specifies that the submesh is ready to be used
  21353. * @param mesh defines the mesh to check
  21354. * @param subMesh defines which submesh to check
  21355. * @param useInstances specifies that instances should be used
  21356. * @returns a boolean indicating that the submesh is ready or not
  21357. */
  21358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21359. /**
  21360. * Returns the material effect
  21361. * @returns the effect associated with the material
  21362. */
  21363. getEffect(): Nullable<Effect>;
  21364. /**
  21365. * Returns the current scene
  21366. * @returns a Scene
  21367. */
  21368. getScene(): Scene;
  21369. /**
  21370. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21371. */
  21372. protected _forceAlphaTest: boolean;
  21373. /**
  21374. * The transparency mode of the material.
  21375. */
  21376. protected _transparencyMode: Nullable<number>;
  21377. /**
  21378. * Gets the current transparency mode.
  21379. */
  21380. get transparencyMode(): Nullable<number>;
  21381. /**
  21382. * Sets the transparency mode of the material.
  21383. *
  21384. * | Value | Type | Description |
  21385. * | ----- | ----------------------------------- | ----------- |
  21386. * | 0 | OPAQUE | |
  21387. * | 1 | ALPHATEST | |
  21388. * | 2 | ALPHABLEND | |
  21389. * | 3 | ALPHATESTANDBLEND | |
  21390. *
  21391. */
  21392. set transparencyMode(value: Nullable<number>);
  21393. /**
  21394. * Returns true if alpha blending should be disabled.
  21395. */
  21396. protected get _disableAlphaBlending(): boolean;
  21397. /**
  21398. * Specifies whether or not this material should be rendered in alpha blend mode.
  21399. * @returns a boolean specifying if alpha blending is needed
  21400. */
  21401. needAlphaBlending(): boolean;
  21402. /**
  21403. * Specifies if the mesh will require alpha blending
  21404. * @param mesh defines the mesh to check
  21405. * @returns a boolean specifying if alpha blending is needed for the mesh
  21406. */
  21407. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21408. /**
  21409. * Specifies whether or not this material should be rendered in alpha test mode.
  21410. * @returns a boolean specifying if an alpha test is needed.
  21411. */
  21412. needAlphaTesting(): boolean;
  21413. /**
  21414. * Specifies if material alpha testing should be turned on for the mesh
  21415. * @param mesh defines the mesh to check
  21416. */
  21417. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21418. /**
  21419. * Gets the texture used for the alpha test
  21420. * @returns the texture to use for alpha testing
  21421. */
  21422. getAlphaTestTexture(): Nullable<BaseTexture>;
  21423. /**
  21424. * Marks the material to indicate that it needs to be re-calculated
  21425. */
  21426. markDirty(): void;
  21427. /** @hidden */
  21428. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21429. /**
  21430. * Binds the material to the mesh
  21431. * @param world defines the world transformation matrix
  21432. * @param mesh defines the mesh to bind the material to
  21433. */
  21434. bind(world: Matrix, mesh?: Mesh): void;
  21435. /**
  21436. * Binds the submesh to the material
  21437. * @param world defines the world transformation matrix
  21438. * @param mesh defines the mesh containing the submesh
  21439. * @param subMesh defines the submesh to bind the material to
  21440. */
  21441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21442. /**
  21443. * Binds the world matrix to the material
  21444. * @param world defines the world transformation matrix
  21445. */
  21446. bindOnlyWorldMatrix(world: Matrix): void;
  21447. /**
  21448. * Binds the scene's uniform buffer to the effect.
  21449. * @param effect defines the effect to bind to the scene uniform buffer
  21450. * @param sceneUbo defines the uniform buffer storing scene data
  21451. */
  21452. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21453. /**
  21454. * Binds the view matrix to the effect
  21455. * @param effect defines the effect to bind the view matrix to
  21456. */
  21457. bindView(effect: Effect): void;
  21458. /**
  21459. * Binds the view projection matrix to the effect
  21460. * @param effect defines the effect to bind the view projection matrix to
  21461. */
  21462. bindViewProjection(effect: Effect): void;
  21463. /**
  21464. * Processes to execute after binding the material to a mesh
  21465. * @param mesh defines the rendered mesh
  21466. */
  21467. protected _afterBind(mesh?: Mesh): void;
  21468. /**
  21469. * Unbinds the material from the mesh
  21470. */
  21471. unbind(): void;
  21472. /**
  21473. * Gets the active textures from the material
  21474. * @returns an array of textures
  21475. */
  21476. getActiveTextures(): BaseTexture[];
  21477. /**
  21478. * Specifies if the material uses a texture
  21479. * @param texture defines the texture to check against the material
  21480. * @returns a boolean specifying if the material uses the texture
  21481. */
  21482. hasTexture(texture: BaseTexture): boolean;
  21483. /**
  21484. * Makes a duplicate of the material, and gives it a new name
  21485. * @param name defines the new name for the duplicated material
  21486. * @returns the cloned material
  21487. */
  21488. clone(name: string): Nullable<Material>;
  21489. /**
  21490. * Gets the meshes bound to the material
  21491. * @returns an array of meshes bound to the material
  21492. */
  21493. getBindedMeshes(): AbstractMesh[];
  21494. /**
  21495. * Force shader compilation
  21496. * @param mesh defines the mesh associated with this material
  21497. * @param onCompiled defines a function to execute once the material is compiled
  21498. * @param options defines the options to configure the compilation
  21499. * @param onError defines a function to execute if the material fails compiling
  21500. */
  21501. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21502. /**
  21503. * Force shader compilation
  21504. * @param mesh defines the mesh that will use this material
  21505. * @param options defines additional options for compiling the shaders
  21506. * @returns a promise that resolves when the compilation completes
  21507. */
  21508. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21509. private static readonly _AllDirtyCallBack;
  21510. private static readonly _ImageProcessingDirtyCallBack;
  21511. private static readonly _TextureDirtyCallBack;
  21512. private static readonly _FresnelDirtyCallBack;
  21513. private static readonly _MiscDirtyCallBack;
  21514. private static readonly _LightsDirtyCallBack;
  21515. private static readonly _AttributeDirtyCallBack;
  21516. private static _FresnelAndMiscDirtyCallBack;
  21517. private static _TextureAndMiscDirtyCallBack;
  21518. private static readonly _DirtyCallbackArray;
  21519. private static readonly _RunDirtyCallBacks;
  21520. /**
  21521. * Marks a define in the material to indicate that it needs to be re-computed
  21522. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21523. */
  21524. markAsDirty(flag: number): void;
  21525. /**
  21526. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21527. * @param func defines a function which checks material defines against the submeshes
  21528. */
  21529. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21530. /**
  21531. * Indicates that we need to re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsAllDirty(): void;
  21534. /**
  21535. * Indicates that image processing needs to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21538. /**
  21539. * Indicates that textures need to be re-calculated for all submeshes
  21540. */
  21541. protected _markAllSubMeshesAsTexturesDirty(): void;
  21542. /**
  21543. * Indicates that fresnel needs to be re-calculated for all submeshes
  21544. */
  21545. protected _markAllSubMeshesAsFresnelDirty(): void;
  21546. /**
  21547. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21548. */
  21549. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21550. /**
  21551. * Indicates that lights need to be re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsLightsDirty(): void;
  21554. /**
  21555. * Indicates that attributes need to be re-calculated for all submeshes
  21556. */
  21557. protected _markAllSubMeshesAsAttributesDirty(): void;
  21558. /**
  21559. * Indicates that misc needs to be re-calculated for all submeshes
  21560. */
  21561. protected _markAllSubMeshesAsMiscDirty(): void;
  21562. /**
  21563. * Indicates that textures and misc need to be re-calculated for all submeshes
  21564. */
  21565. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21566. /**
  21567. * Disposes the material
  21568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21571. */
  21572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21573. /** @hidden */
  21574. private releaseVertexArrayObject;
  21575. /**
  21576. * Serializes this material
  21577. * @returns the serialized material object
  21578. */
  21579. serialize(): any;
  21580. /**
  21581. * Creates a material from parsed material data
  21582. * @param parsedMaterial defines parsed material data
  21583. * @param scene defines the hosting scene
  21584. * @param rootUrl defines the root URL to use to load textures
  21585. * @returns a new material
  21586. */
  21587. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21588. }
  21589. }
  21590. declare module BABYLON {
  21591. /**
  21592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21593. * separate meshes. This can be use to improve performances.
  21594. * @see http://doc.babylonjs.com/how_to/multi_materials
  21595. */
  21596. export class MultiMaterial extends Material {
  21597. private _subMaterials;
  21598. /**
  21599. * Gets or Sets the list of Materials used within the multi material.
  21600. * They need to be ordered according to the submeshes order in the associated mesh
  21601. */
  21602. get subMaterials(): Nullable<Material>[];
  21603. set subMaterials(value: Nullable<Material>[]);
  21604. /**
  21605. * Function used to align with Node.getChildren()
  21606. * @returns the list of Materials used within the multi material
  21607. */
  21608. getChildren(): Nullable<Material>[];
  21609. /**
  21610. * Instantiates a new Multi Material
  21611. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21612. * separate meshes. This can be use to improve performances.
  21613. * @see http://doc.babylonjs.com/how_to/multi_materials
  21614. * @param name Define the name in the scene
  21615. * @param scene Define the scene the material belongs to
  21616. */
  21617. constructor(name: string, scene: Scene);
  21618. private _hookArray;
  21619. /**
  21620. * Get one of the submaterial by its index in the submaterials array
  21621. * @param index The index to look the sub material at
  21622. * @returns The Material if the index has been defined
  21623. */
  21624. getSubMaterial(index: number): Nullable<Material>;
  21625. /**
  21626. * Get the list of active textures for the whole sub materials list.
  21627. * @returns All the textures that will be used during the rendering
  21628. */
  21629. getActiveTextures(): BaseTexture[];
  21630. /**
  21631. * Gets the current class name of the material e.g. "MultiMaterial"
  21632. * Mainly use in serialization.
  21633. * @returns the class name
  21634. */
  21635. getClassName(): string;
  21636. /**
  21637. * Checks if the material is ready to render the requested sub mesh
  21638. * @param mesh Define the mesh the submesh belongs to
  21639. * @param subMesh Define the sub mesh to look readyness for
  21640. * @param useInstances Define whether or not the material is used with instances
  21641. * @returns true if ready, otherwise false
  21642. */
  21643. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21644. /**
  21645. * Clones the current material and its related sub materials
  21646. * @param name Define the name of the newly cloned material
  21647. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21648. * @returns the cloned material
  21649. */
  21650. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21651. /**
  21652. * Serializes the materials into a JSON representation.
  21653. * @returns the JSON representation
  21654. */
  21655. serialize(): any;
  21656. /**
  21657. * Dispose the material and release its associated resources
  21658. * @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)
  21659. * @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)
  21660. * @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)
  21661. */
  21662. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21663. /**
  21664. * Creates a MultiMaterial from parsed MultiMaterial data.
  21665. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21666. * @param scene defines the hosting scene
  21667. * @returns a new MultiMaterial
  21668. */
  21669. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21670. }
  21671. }
  21672. declare module BABYLON {
  21673. /**
  21674. * Base class for submeshes
  21675. */
  21676. export class BaseSubMesh {
  21677. /** @hidden */
  21678. _materialDefines: Nullable<MaterialDefines>;
  21679. /** @hidden */
  21680. _materialEffect: Nullable<Effect>;
  21681. /**
  21682. * Gets material defines used by the effect associated to the sub mesh
  21683. */
  21684. get materialDefines(): Nullable<MaterialDefines>;
  21685. /**
  21686. * Sets material defines used by the effect associated to the sub mesh
  21687. */
  21688. set materialDefines(defines: Nullable<MaterialDefines>);
  21689. /**
  21690. * Gets associated effect
  21691. */
  21692. get effect(): Nullable<Effect>;
  21693. /**
  21694. * Sets associated effect (effect used to render this submesh)
  21695. * @param effect defines the effect to associate with
  21696. * @param defines defines the set of defines used to compile this effect
  21697. */
  21698. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21699. }
  21700. /**
  21701. * Defines a subdivision inside a mesh
  21702. */
  21703. export class SubMesh extends BaseSubMesh implements ICullable {
  21704. /** the material index to use */
  21705. materialIndex: number;
  21706. /** vertex index start */
  21707. verticesStart: number;
  21708. /** vertices count */
  21709. verticesCount: number;
  21710. /** index start */
  21711. indexStart: number;
  21712. /** indices count */
  21713. indexCount: number;
  21714. /** @hidden */
  21715. _linesIndexCount: number;
  21716. private _mesh;
  21717. private _renderingMesh;
  21718. private _boundingInfo;
  21719. private _linesIndexBuffer;
  21720. /** @hidden */
  21721. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21722. /** @hidden */
  21723. _trianglePlanes: Plane[];
  21724. /** @hidden */
  21725. _lastColliderTransformMatrix: Nullable<Matrix>;
  21726. /** @hidden */
  21727. _renderId: number;
  21728. /** @hidden */
  21729. _alphaIndex: number;
  21730. /** @hidden */
  21731. _distanceToCamera: number;
  21732. /** @hidden */
  21733. _id: number;
  21734. private _currentMaterial;
  21735. /**
  21736. * Add a new submesh to a mesh
  21737. * @param materialIndex defines the material index to use
  21738. * @param verticesStart defines vertex index start
  21739. * @param verticesCount defines vertices count
  21740. * @param indexStart defines index start
  21741. * @param indexCount defines indices count
  21742. * @param mesh defines the parent mesh
  21743. * @param renderingMesh defines an optional rendering mesh
  21744. * @param createBoundingBox defines if bounding box should be created for this submesh
  21745. * @returns the new submesh
  21746. */
  21747. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21748. /**
  21749. * Creates a new submesh
  21750. * @param materialIndex defines the material index to use
  21751. * @param verticesStart defines vertex index start
  21752. * @param verticesCount defines vertices count
  21753. * @param indexStart defines index start
  21754. * @param indexCount defines indices count
  21755. * @param mesh defines the parent mesh
  21756. * @param renderingMesh defines an optional rendering mesh
  21757. * @param createBoundingBox defines if bounding box should be created for this submesh
  21758. */
  21759. constructor(
  21760. /** the material index to use */
  21761. materialIndex: number,
  21762. /** vertex index start */
  21763. verticesStart: number,
  21764. /** vertices count */
  21765. verticesCount: number,
  21766. /** index start */
  21767. indexStart: number,
  21768. /** indices count */
  21769. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21770. /**
  21771. * Returns true if this submesh covers the entire parent mesh
  21772. * @ignorenaming
  21773. */
  21774. get IsGlobal(): boolean;
  21775. /**
  21776. * Returns the submesh BoudingInfo object
  21777. * @returns current bounding info (or mesh's one if the submesh is global)
  21778. */
  21779. getBoundingInfo(): BoundingInfo;
  21780. /**
  21781. * Sets the submesh BoundingInfo
  21782. * @param boundingInfo defines the new bounding info to use
  21783. * @returns the SubMesh
  21784. */
  21785. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21786. /**
  21787. * Returns the mesh of the current submesh
  21788. * @return the parent mesh
  21789. */
  21790. getMesh(): AbstractMesh;
  21791. /**
  21792. * Returns the rendering mesh of the submesh
  21793. * @returns the rendering mesh (could be different from parent mesh)
  21794. */
  21795. getRenderingMesh(): Mesh;
  21796. /**
  21797. * Returns the submesh material
  21798. * @returns null or the current material
  21799. */
  21800. getMaterial(): Nullable<Material>;
  21801. /**
  21802. * Sets a new updated BoundingInfo object to the submesh
  21803. * @param data defines an optional position array to use to determine the bounding info
  21804. * @returns the SubMesh
  21805. */
  21806. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21807. /** @hidden */
  21808. _checkCollision(collider: Collider): boolean;
  21809. /**
  21810. * Updates the submesh BoundingInfo
  21811. * @param world defines the world matrix to use to update the bounding info
  21812. * @returns the submesh
  21813. */
  21814. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21815. /**
  21816. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21817. * @param frustumPlanes defines the frustum planes
  21818. * @returns true if the submesh is intersecting with the frustum
  21819. */
  21820. isInFrustum(frustumPlanes: Plane[]): boolean;
  21821. /**
  21822. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21823. * @param frustumPlanes defines the frustum planes
  21824. * @returns true if the submesh is inside the frustum
  21825. */
  21826. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21827. /**
  21828. * Renders the submesh
  21829. * @param enableAlphaMode defines if alpha needs to be used
  21830. * @returns the submesh
  21831. */
  21832. render(enableAlphaMode: boolean): SubMesh;
  21833. /**
  21834. * @hidden
  21835. */
  21836. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21837. /**
  21838. * Checks if the submesh intersects with a ray
  21839. * @param ray defines the ray to test
  21840. * @returns true is the passed ray intersects the submesh bounding box
  21841. */
  21842. canIntersects(ray: Ray): boolean;
  21843. /**
  21844. * Intersects current submesh with a ray
  21845. * @param ray defines the ray to test
  21846. * @param positions defines mesh's positions array
  21847. * @param indices defines mesh's indices array
  21848. * @param fastCheck defines if only bounding info should be used
  21849. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21850. * @returns intersection info or null if no intersection
  21851. */
  21852. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21853. /** @hidden */
  21854. private _intersectLines;
  21855. /** @hidden */
  21856. private _intersectUnIndexedLines;
  21857. /** @hidden */
  21858. private _intersectTriangles;
  21859. /** @hidden */
  21860. private _intersectUnIndexedTriangles;
  21861. /** @hidden */
  21862. _rebuild(): void;
  21863. /**
  21864. * Creates a new submesh from the passed mesh
  21865. * @param newMesh defines the new hosting mesh
  21866. * @param newRenderingMesh defines an optional rendering mesh
  21867. * @returns the new submesh
  21868. */
  21869. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21870. /**
  21871. * Release associated resources
  21872. */
  21873. dispose(): void;
  21874. /**
  21875. * Gets the class name
  21876. * @returns the string "SubMesh".
  21877. */
  21878. getClassName(): string;
  21879. /**
  21880. * Creates a new submesh from indices data
  21881. * @param materialIndex the index of the main mesh material
  21882. * @param startIndex the index where to start the copy in the mesh indices array
  21883. * @param indexCount the number of indices to copy then from the startIndex
  21884. * @param mesh the main mesh to create the submesh from
  21885. * @param renderingMesh the optional rendering mesh
  21886. * @returns a new submesh
  21887. */
  21888. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21889. }
  21890. }
  21891. declare module BABYLON {
  21892. /**
  21893. * Class used to represent data loading progression
  21894. */
  21895. export class SceneLoaderFlags {
  21896. private static _ForceFullSceneLoadingForIncremental;
  21897. private static _ShowLoadingScreen;
  21898. private static _CleanBoneMatrixWeights;
  21899. private static _loggingLevel;
  21900. /**
  21901. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21902. */
  21903. static get ForceFullSceneLoadingForIncremental(): boolean;
  21904. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21905. /**
  21906. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21907. */
  21908. static get ShowLoadingScreen(): boolean;
  21909. static set ShowLoadingScreen(value: boolean);
  21910. /**
  21911. * Defines the current logging level (while loading the scene)
  21912. * @ignorenaming
  21913. */
  21914. static get loggingLevel(): number;
  21915. static set loggingLevel(value: number);
  21916. /**
  21917. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21918. */
  21919. static get CleanBoneMatrixWeights(): boolean;
  21920. static set CleanBoneMatrixWeights(value: boolean);
  21921. }
  21922. }
  21923. declare module BABYLON {
  21924. /**
  21925. * Class used to store geometry data (vertex buffers + index buffer)
  21926. */
  21927. export class Geometry implements IGetSetVerticesData {
  21928. /**
  21929. * Gets or sets the ID of the geometry
  21930. */
  21931. id: string;
  21932. /**
  21933. * Gets or sets the unique ID of the geometry
  21934. */
  21935. uniqueId: number;
  21936. /**
  21937. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21938. */
  21939. delayLoadState: number;
  21940. /**
  21941. * Gets the file containing the data to load when running in delay load state
  21942. */
  21943. delayLoadingFile: Nullable<string>;
  21944. /**
  21945. * Callback called when the geometry is updated
  21946. */
  21947. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21948. private _scene;
  21949. private _engine;
  21950. private _meshes;
  21951. private _totalVertices;
  21952. /** @hidden */
  21953. _indices: IndicesArray;
  21954. /** @hidden */
  21955. _vertexBuffers: {
  21956. [key: string]: VertexBuffer;
  21957. };
  21958. private _isDisposed;
  21959. private _extend;
  21960. private _boundingBias;
  21961. /** @hidden */
  21962. _delayInfo: Array<string>;
  21963. private _indexBuffer;
  21964. private _indexBufferIsUpdatable;
  21965. /** @hidden */
  21966. _boundingInfo: Nullable<BoundingInfo>;
  21967. /** @hidden */
  21968. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21969. /** @hidden */
  21970. _softwareSkinningFrameId: number;
  21971. private _vertexArrayObjects;
  21972. private _updatable;
  21973. /** @hidden */
  21974. _positions: Nullable<Vector3[]>;
  21975. /**
  21976. * 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
  21977. */
  21978. get boundingBias(): Vector2;
  21979. /**
  21980. * 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
  21981. */
  21982. set boundingBias(value: Vector2);
  21983. /**
  21984. * Static function used to attach a new empty geometry to a mesh
  21985. * @param mesh defines the mesh to attach the geometry to
  21986. * @returns the new Geometry
  21987. */
  21988. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21989. /** Get the list of meshes using this geometry */
  21990. get meshes(): Mesh[];
  21991. /**
  21992. * Creates a new geometry
  21993. * @param id defines the unique ID
  21994. * @param scene defines the hosting scene
  21995. * @param vertexData defines the VertexData used to get geometry data
  21996. * @param updatable defines if geometry must be updatable (false by default)
  21997. * @param mesh defines the mesh that will be associated with the geometry
  21998. */
  21999. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22000. /**
  22001. * Gets the current extend of the geometry
  22002. */
  22003. get extend(): {
  22004. minimum: Vector3;
  22005. maximum: Vector3;
  22006. };
  22007. /**
  22008. * Gets the hosting scene
  22009. * @returns the hosting Scene
  22010. */
  22011. getScene(): Scene;
  22012. /**
  22013. * Gets the hosting engine
  22014. * @returns the hosting Engine
  22015. */
  22016. getEngine(): Engine;
  22017. /**
  22018. * Defines if the geometry is ready to use
  22019. * @returns true if the geometry is ready to be used
  22020. */
  22021. isReady(): boolean;
  22022. /**
  22023. * Gets a value indicating that the geometry should not be serialized
  22024. */
  22025. get doNotSerialize(): boolean;
  22026. /** @hidden */
  22027. _rebuild(): void;
  22028. /**
  22029. * Affects all geometry data in one call
  22030. * @param vertexData defines the geometry data
  22031. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22032. */
  22033. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22034. /**
  22035. * Set specific vertex data
  22036. * @param kind defines the data kind (Position, normal, etc...)
  22037. * @param data defines the vertex data to use
  22038. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22039. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22040. */
  22041. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22042. /**
  22043. * Removes a specific vertex data
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. */
  22046. removeVerticesData(kind: string): void;
  22047. /**
  22048. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22049. * @param buffer defines the vertex buffer to use
  22050. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22051. */
  22052. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22053. /**
  22054. * Update a specific vertex buffer
  22055. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22056. * It will do nothing if the buffer is not updatable
  22057. * @param kind defines the data kind (Position, normal, etc...)
  22058. * @param data defines the data to use
  22059. * @param offset defines the offset in the target buffer where to store the data
  22060. * @param useBytes set to true if the offset is in bytes
  22061. */
  22062. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22063. /**
  22064. * Update a specific vertex buffer
  22065. * This function will create a new buffer if the current one is not updatable
  22066. * @param kind defines the data kind (Position, normal, etc...)
  22067. * @param data defines the data to use
  22068. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22069. */
  22070. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22071. private _updateBoundingInfo;
  22072. /** @hidden */
  22073. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22074. /**
  22075. * Gets total number of vertices
  22076. * @returns the total number of vertices
  22077. */
  22078. getTotalVertices(): number;
  22079. /**
  22080. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22081. * @param kind defines the data kind (Position, normal, etc...)
  22082. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22083. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22084. * @returns a float array containing vertex data
  22085. */
  22086. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22087. /**
  22088. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22089. * @param kind defines the data kind (Position, normal, etc...)
  22090. * @returns true if the vertex buffer with the specified kind is updatable
  22091. */
  22092. isVertexBufferUpdatable(kind: string): boolean;
  22093. /**
  22094. * Gets a specific vertex buffer
  22095. * @param kind defines the data kind (Position, normal, etc...)
  22096. * @returns a VertexBuffer
  22097. */
  22098. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22099. /**
  22100. * Returns all vertex buffers
  22101. * @return an object holding all vertex buffers indexed by kind
  22102. */
  22103. getVertexBuffers(): Nullable<{
  22104. [key: string]: VertexBuffer;
  22105. }>;
  22106. /**
  22107. * Gets a boolean indicating if specific vertex buffer is present
  22108. * @param kind defines the data kind (Position, normal, etc...)
  22109. * @returns true if data is present
  22110. */
  22111. isVerticesDataPresent(kind: string): boolean;
  22112. /**
  22113. * Gets a list of all attached data kinds (Position, normal, etc...)
  22114. * @returns a list of string containing all kinds
  22115. */
  22116. getVerticesDataKinds(): string[];
  22117. /**
  22118. * Update index buffer
  22119. * @param indices defines the indices to store in the index buffer
  22120. * @param offset defines the offset in the target buffer where to store the data
  22121. * @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)
  22122. */
  22123. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22124. /**
  22125. * Creates a new index buffer
  22126. * @param indices defines the indices to store in the index buffer
  22127. * @param totalVertices defines the total number of vertices (could be null)
  22128. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22129. */
  22130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22131. /**
  22132. * Return the total number of indices
  22133. * @returns the total number of indices
  22134. */
  22135. getTotalIndices(): number;
  22136. /**
  22137. * Gets the index buffer array
  22138. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22139. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22140. * @returns the index buffer array
  22141. */
  22142. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22143. /**
  22144. * Gets the index buffer
  22145. * @return the index buffer
  22146. */
  22147. getIndexBuffer(): Nullable<DataBuffer>;
  22148. /** @hidden */
  22149. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22150. /**
  22151. * Release the associated resources for a specific mesh
  22152. * @param mesh defines the source mesh
  22153. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22154. */
  22155. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22156. /**
  22157. * Apply current geometry to a given mesh
  22158. * @param mesh defines the mesh to apply geometry to
  22159. */
  22160. applyToMesh(mesh: Mesh): void;
  22161. private _updateExtend;
  22162. private _applyToMesh;
  22163. private notifyUpdate;
  22164. /**
  22165. * Load the geometry if it was flagged as delay loaded
  22166. * @param scene defines the hosting scene
  22167. * @param onLoaded defines a callback called when the geometry is loaded
  22168. */
  22169. load(scene: Scene, onLoaded?: () => void): void;
  22170. private _queueLoad;
  22171. /**
  22172. * Invert the geometry to move from a right handed system to a left handed one.
  22173. */
  22174. toLeftHanded(): void;
  22175. /** @hidden */
  22176. _resetPointsArrayCache(): void;
  22177. /** @hidden */
  22178. _generatePointsArray(): boolean;
  22179. /**
  22180. * Gets a value indicating if the geometry is disposed
  22181. * @returns true if the geometry was disposed
  22182. */
  22183. isDisposed(): boolean;
  22184. private _disposeVertexArrayObjects;
  22185. /**
  22186. * Free all associated resources
  22187. */
  22188. dispose(): void;
  22189. /**
  22190. * Clone the current geometry into a new geometry
  22191. * @param id defines the unique ID of the new geometry
  22192. * @returns a new geometry object
  22193. */
  22194. copy(id: string): Geometry;
  22195. /**
  22196. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22197. * @return a JSON representation of the current geometry data (without the vertices data)
  22198. */
  22199. serialize(): any;
  22200. private toNumberArray;
  22201. /**
  22202. * Serialize all vertices data into a JSON oject
  22203. * @returns a JSON representation of the current geometry data
  22204. */
  22205. serializeVerticeData(): any;
  22206. /**
  22207. * Extracts a clone of a mesh geometry
  22208. * @param mesh defines the source mesh
  22209. * @param id defines the unique ID of the new geometry object
  22210. * @returns the new geometry object
  22211. */
  22212. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22213. /**
  22214. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22215. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22216. * Be aware Math.random() could cause collisions, but:
  22217. * "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"
  22218. * @returns a string containing a new GUID
  22219. */
  22220. static RandomId(): string;
  22221. /** @hidden */
  22222. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22223. private static _CleanMatricesWeights;
  22224. /**
  22225. * Create a new geometry from persisted data (Using .babylon file format)
  22226. * @param parsedVertexData defines the persisted data
  22227. * @param scene defines the hosting scene
  22228. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22229. * @returns the new geometry object
  22230. */
  22231. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22232. }
  22233. }
  22234. declare module BABYLON {
  22235. /**
  22236. * Define an interface for all classes that will get and set the data on vertices
  22237. */
  22238. export interface IGetSetVerticesData {
  22239. /**
  22240. * Gets a boolean indicating if specific vertex data is present
  22241. * @param kind defines the vertex data kind to use
  22242. * @returns true is data kind is present
  22243. */
  22244. isVerticesDataPresent(kind: string): boolean;
  22245. /**
  22246. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22247. * @param kind defines the data kind (Position, normal, etc...)
  22248. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22249. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22250. * @returns a float array containing vertex data
  22251. */
  22252. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22253. /**
  22254. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22255. * @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.
  22256. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22257. * @returns the indices array or an empty array if the mesh has no geometry
  22258. */
  22259. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22260. /**
  22261. * Set specific vertex data
  22262. * @param kind defines the data kind (Position, normal, etc...)
  22263. * @param data defines the vertex data to use
  22264. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22265. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22266. */
  22267. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22268. /**
  22269. * Update a specific associated vertex buffer
  22270. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22271. * - VertexBuffer.PositionKind
  22272. * - VertexBuffer.UVKind
  22273. * - VertexBuffer.UV2Kind
  22274. * - VertexBuffer.UV3Kind
  22275. * - VertexBuffer.UV4Kind
  22276. * - VertexBuffer.UV5Kind
  22277. * - VertexBuffer.UV6Kind
  22278. * - VertexBuffer.ColorKind
  22279. * - VertexBuffer.MatricesIndicesKind
  22280. * - VertexBuffer.MatricesIndicesExtraKind
  22281. * - VertexBuffer.MatricesWeightsKind
  22282. * - VertexBuffer.MatricesWeightsExtraKind
  22283. * @param data defines the data source
  22284. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22285. * @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)
  22286. */
  22287. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22288. /**
  22289. * Creates a new index buffer
  22290. * @param indices defines the indices to store in the index buffer
  22291. * @param totalVertices defines the total number of vertices (could be null)
  22292. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22293. */
  22294. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22295. }
  22296. /**
  22297. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22298. */
  22299. export class VertexData {
  22300. /**
  22301. * Mesh side orientation : usually the external or front surface
  22302. */
  22303. static readonly FRONTSIDE: number;
  22304. /**
  22305. * Mesh side orientation : usually the internal or back surface
  22306. */
  22307. static readonly BACKSIDE: number;
  22308. /**
  22309. * Mesh side orientation : both internal and external or front and back surfaces
  22310. */
  22311. static readonly DOUBLESIDE: number;
  22312. /**
  22313. * Mesh side orientation : by default, `FRONTSIDE`
  22314. */
  22315. static readonly DEFAULTSIDE: number;
  22316. /**
  22317. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22318. */
  22319. positions: Nullable<FloatArray>;
  22320. /**
  22321. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22322. */
  22323. normals: Nullable<FloatArray>;
  22324. /**
  22325. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22326. */
  22327. tangents: Nullable<FloatArray>;
  22328. /**
  22329. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22330. */
  22331. uvs: Nullable<FloatArray>;
  22332. /**
  22333. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22334. */
  22335. uvs2: Nullable<FloatArray>;
  22336. /**
  22337. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22338. */
  22339. uvs3: Nullable<FloatArray>;
  22340. /**
  22341. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22342. */
  22343. uvs4: Nullable<FloatArray>;
  22344. /**
  22345. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22346. */
  22347. uvs5: Nullable<FloatArray>;
  22348. /**
  22349. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22350. */
  22351. uvs6: Nullable<FloatArray>;
  22352. /**
  22353. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22354. */
  22355. colors: Nullable<FloatArray>;
  22356. /**
  22357. * 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).
  22358. */
  22359. matricesIndices: Nullable<FloatArray>;
  22360. /**
  22361. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22362. */
  22363. matricesWeights: Nullable<FloatArray>;
  22364. /**
  22365. * An array extending the number of possible indices
  22366. */
  22367. matricesIndicesExtra: Nullable<FloatArray>;
  22368. /**
  22369. * An array extending the number of possible weights when the number of indices is extended
  22370. */
  22371. matricesWeightsExtra: Nullable<FloatArray>;
  22372. /**
  22373. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22374. */
  22375. indices: Nullable<IndicesArray>;
  22376. /**
  22377. * Uses the passed data array to set the set the values for the specified kind of data
  22378. * @param data a linear array of floating numbers
  22379. * @param kind the type of data that is being set, eg positions, colors etc
  22380. */
  22381. set(data: FloatArray, kind: string): void;
  22382. /**
  22383. * Associates the vertexData to the passed Mesh.
  22384. * Sets it as updatable or not (default `false`)
  22385. * @param mesh the mesh the vertexData is applied to
  22386. * @param updatable when used and having the value true allows new data to update the vertexData
  22387. * @returns the VertexData
  22388. */
  22389. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22390. /**
  22391. * Associates the vertexData to the passed Geometry.
  22392. * Sets it as updatable or not (default `false`)
  22393. * @param geometry the geometry the vertexData is applied to
  22394. * @param updatable when used and having the value true allows new data to update the vertexData
  22395. * @returns VertexData
  22396. */
  22397. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22398. /**
  22399. * Updates the associated mesh
  22400. * @param mesh the mesh to be updated
  22401. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22402. * @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
  22403. * @returns VertexData
  22404. */
  22405. updateMesh(mesh: Mesh): VertexData;
  22406. /**
  22407. * Updates the associated geometry
  22408. * @param geometry the geometry to be updated
  22409. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22410. * @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
  22411. * @returns VertexData.
  22412. */
  22413. updateGeometry(geometry: Geometry): VertexData;
  22414. private _applyTo;
  22415. private _update;
  22416. /**
  22417. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22418. * @param matrix the transforming matrix
  22419. * @returns the VertexData
  22420. */
  22421. transform(matrix: Matrix): VertexData;
  22422. /**
  22423. * Merges the passed VertexData into the current one
  22424. * @param other the VertexData to be merged into the current one
  22425. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22426. * @returns the modified VertexData
  22427. */
  22428. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22429. private _mergeElement;
  22430. private _validate;
  22431. /**
  22432. * Serializes the VertexData
  22433. * @returns a serialized object
  22434. */
  22435. serialize(): any;
  22436. /**
  22437. * Extracts the vertexData from a mesh
  22438. * @param mesh the mesh from which to extract the VertexData
  22439. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22440. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22441. * @returns the object VertexData associated to the passed mesh
  22442. */
  22443. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22444. /**
  22445. * Extracts the vertexData from the geometry
  22446. * @param geometry the geometry from which to extract the VertexData
  22447. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22448. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22449. * @returns the object VertexData associated to the passed mesh
  22450. */
  22451. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22452. private static _ExtractFrom;
  22453. /**
  22454. * Creates the VertexData for a Ribbon
  22455. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22456. * * pathArray array of paths, each of which an array of successive Vector3
  22457. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22458. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22459. * * 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
  22460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22461. * * 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)
  22462. * * 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)
  22463. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22464. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22465. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22466. * @returns the VertexData of the ribbon
  22467. */
  22468. static CreateRibbon(options: {
  22469. pathArray: Vector3[][];
  22470. closeArray?: boolean;
  22471. closePath?: boolean;
  22472. offset?: number;
  22473. sideOrientation?: number;
  22474. frontUVs?: Vector4;
  22475. backUVs?: Vector4;
  22476. invertUV?: boolean;
  22477. uvs?: Vector2[];
  22478. colors?: Color4[];
  22479. }): VertexData;
  22480. /**
  22481. * Creates the VertexData for a box
  22482. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22483. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22484. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22485. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22486. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22487. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22488. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22490. * * 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)
  22491. * * 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)
  22492. * @returns the VertexData of the box
  22493. */
  22494. static CreateBox(options: {
  22495. size?: number;
  22496. width?: number;
  22497. height?: number;
  22498. depth?: number;
  22499. faceUV?: Vector4[];
  22500. faceColors?: Color4[];
  22501. sideOrientation?: number;
  22502. frontUVs?: Vector4;
  22503. backUVs?: Vector4;
  22504. }): VertexData;
  22505. /**
  22506. * Creates the VertexData for a tiled box
  22507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22508. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22509. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22510. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22512. * @returns the VertexData of the box
  22513. */
  22514. static CreateTiledBox(options: {
  22515. pattern?: number;
  22516. width?: number;
  22517. height?: number;
  22518. depth?: number;
  22519. tileSize?: number;
  22520. tileWidth?: number;
  22521. tileHeight?: number;
  22522. alignHorizontal?: number;
  22523. alignVertical?: number;
  22524. faceUV?: Vector4[];
  22525. faceColors?: Color4[];
  22526. sideOrientation?: number;
  22527. }): VertexData;
  22528. /**
  22529. * Creates the VertexData for a tiled plane
  22530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22531. * * pattern a limited pattern arrangement depending on the number
  22532. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22533. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22534. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22536. * * 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)
  22537. * * 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)
  22538. * @returns the VertexData of the tiled plane
  22539. */
  22540. static CreateTiledPlane(options: {
  22541. pattern?: number;
  22542. tileSize?: number;
  22543. tileWidth?: number;
  22544. tileHeight?: number;
  22545. size?: number;
  22546. width?: number;
  22547. height?: number;
  22548. alignHorizontal?: number;
  22549. alignVertical?: number;
  22550. sideOrientation?: number;
  22551. frontUVs?: Vector4;
  22552. backUVs?: Vector4;
  22553. }): VertexData;
  22554. /**
  22555. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22556. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22557. * * segments sets the number of horizontal strips optional, default 32
  22558. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22559. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22560. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22561. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22562. * * 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
  22563. * * 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
  22564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22565. * * 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)
  22566. * * 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)
  22567. * @returns the VertexData of the ellipsoid
  22568. */
  22569. static CreateSphere(options: {
  22570. segments?: number;
  22571. diameter?: number;
  22572. diameterX?: number;
  22573. diameterY?: number;
  22574. diameterZ?: number;
  22575. arc?: number;
  22576. slice?: number;
  22577. sideOrientation?: number;
  22578. frontUVs?: Vector4;
  22579. backUVs?: Vector4;
  22580. }): VertexData;
  22581. /**
  22582. * Creates the VertexData for a cylinder, cone or prism
  22583. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22584. * * height sets the height (y direction) of the cylinder, optional, default 2
  22585. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22586. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22587. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22588. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22589. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22590. * * 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
  22591. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22592. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22593. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22594. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22596. * * 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)
  22597. * * 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)
  22598. * @returns the VertexData of the cylinder, cone or prism
  22599. */
  22600. static CreateCylinder(options: {
  22601. height?: number;
  22602. diameterTop?: number;
  22603. diameterBottom?: number;
  22604. diameter?: number;
  22605. tessellation?: number;
  22606. subdivisions?: number;
  22607. arc?: number;
  22608. faceColors?: Color4[];
  22609. faceUV?: Vector4[];
  22610. hasRings?: boolean;
  22611. enclose?: boolean;
  22612. sideOrientation?: number;
  22613. frontUVs?: Vector4;
  22614. backUVs?: Vector4;
  22615. }): VertexData;
  22616. /**
  22617. * Creates the VertexData for a torus
  22618. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22619. * * diameter the diameter of the torus, optional default 1
  22620. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22621. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22622. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22623. * * 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)
  22624. * * 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)
  22625. * @returns the VertexData of the torus
  22626. */
  22627. static CreateTorus(options: {
  22628. diameter?: number;
  22629. thickness?: number;
  22630. tessellation?: number;
  22631. sideOrientation?: number;
  22632. frontUVs?: Vector4;
  22633. backUVs?: Vector4;
  22634. }): VertexData;
  22635. /**
  22636. * Creates the VertexData of the LineSystem
  22637. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22638. * - lines an array of lines, each line being an array of successive Vector3
  22639. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22640. * @returns the VertexData of the LineSystem
  22641. */
  22642. static CreateLineSystem(options: {
  22643. lines: Vector3[][];
  22644. colors?: Nullable<Color4[][]>;
  22645. }): VertexData;
  22646. /**
  22647. * Create the VertexData for a DashedLines
  22648. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22649. * - points an array successive Vector3
  22650. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22651. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22652. * - dashNb the intended total number of dashes, optional, default 200
  22653. * @returns the VertexData for the DashedLines
  22654. */
  22655. static CreateDashedLines(options: {
  22656. points: Vector3[];
  22657. dashSize?: number;
  22658. gapSize?: number;
  22659. dashNb?: number;
  22660. }): VertexData;
  22661. /**
  22662. * Creates the VertexData for a Ground
  22663. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22664. * - width the width (x direction) of the ground, optional, default 1
  22665. * - height the height (z direction) of the ground, optional, default 1
  22666. * - subdivisions the number of subdivisions per side, optional, default 1
  22667. * @returns the VertexData of the Ground
  22668. */
  22669. static CreateGround(options: {
  22670. width?: number;
  22671. height?: number;
  22672. subdivisions?: number;
  22673. subdivisionsX?: number;
  22674. subdivisionsY?: number;
  22675. }): VertexData;
  22676. /**
  22677. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22678. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22679. * * xmin the ground minimum X coordinate, optional, default -1
  22680. * * zmin the ground minimum Z coordinate, optional, default -1
  22681. * * xmax the ground maximum X coordinate, optional, default 1
  22682. * * zmax the ground maximum Z coordinate, optional, default 1
  22683. * * 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}
  22684. * * 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}
  22685. * @returns the VertexData of the TiledGround
  22686. */
  22687. static CreateTiledGround(options: {
  22688. xmin: number;
  22689. zmin: number;
  22690. xmax: number;
  22691. zmax: number;
  22692. subdivisions?: {
  22693. w: number;
  22694. h: number;
  22695. };
  22696. precision?: {
  22697. w: number;
  22698. h: number;
  22699. };
  22700. }): VertexData;
  22701. /**
  22702. * Creates the VertexData of the Ground designed from a heightmap
  22703. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22704. * * width the width (x direction) of the ground
  22705. * * height the height (z direction) of the ground
  22706. * * subdivisions the number of subdivisions per side
  22707. * * minHeight the minimum altitude on the ground, optional, default 0
  22708. * * maxHeight the maximum altitude on the ground, optional default 1
  22709. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22710. * * buffer the array holding the image color data
  22711. * * bufferWidth the width of image
  22712. * * bufferHeight the height of image
  22713. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22714. * @returns the VertexData of the Ground designed from a heightmap
  22715. */
  22716. static CreateGroundFromHeightMap(options: {
  22717. width: number;
  22718. height: number;
  22719. subdivisions: number;
  22720. minHeight: number;
  22721. maxHeight: number;
  22722. colorFilter: Color3;
  22723. buffer: Uint8Array;
  22724. bufferWidth: number;
  22725. bufferHeight: number;
  22726. alphaFilter: number;
  22727. }): VertexData;
  22728. /**
  22729. * Creates the VertexData for a Plane
  22730. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22731. * * size sets the width and height of the plane to the value of size, optional default 1
  22732. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22733. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22734. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22735. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22736. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22737. * @returns the VertexData of the box
  22738. */
  22739. static CreatePlane(options: {
  22740. size?: number;
  22741. width?: number;
  22742. height?: number;
  22743. sideOrientation?: number;
  22744. frontUVs?: Vector4;
  22745. backUVs?: Vector4;
  22746. }): VertexData;
  22747. /**
  22748. * Creates the VertexData of the Disc or regular Polygon
  22749. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22750. * * radius the radius of the disc, optional default 0.5
  22751. * * tessellation the number of polygon sides, optional, default 64
  22752. * * 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
  22753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22754. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22755. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22756. * @returns the VertexData of the box
  22757. */
  22758. static CreateDisc(options: {
  22759. radius?: number;
  22760. tessellation?: number;
  22761. arc?: number;
  22762. sideOrientation?: number;
  22763. frontUVs?: Vector4;
  22764. backUVs?: Vector4;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22768. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22769. * @param polygon a mesh built from polygonTriangulation.build()
  22770. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22771. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22772. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22773. * @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)
  22774. * @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)
  22775. * @returns the VertexData of the Polygon
  22776. */
  22777. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22778. /**
  22779. * Creates the VertexData of the IcoSphere
  22780. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22781. * * radius the radius of the IcoSphere, optional default 1
  22782. * * radiusX allows stretching in the x direction, optional, default radius
  22783. * * radiusY allows stretching in the y direction, optional, default radius
  22784. * * radiusZ allows stretching in the z direction, optional, default radius
  22785. * * flat when true creates a flat shaded mesh, optional, default true
  22786. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22787. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22788. * * 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)
  22789. * * 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)
  22790. * @returns the VertexData of the IcoSphere
  22791. */
  22792. static CreateIcoSphere(options: {
  22793. radius?: number;
  22794. radiusX?: number;
  22795. radiusY?: number;
  22796. radiusZ?: number;
  22797. flat?: boolean;
  22798. subdivisions?: number;
  22799. sideOrientation?: number;
  22800. frontUVs?: Vector4;
  22801. backUVs?: Vector4;
  22802. }): VertexData;
  22803. /**
  22804. * Creates the VertexData for a Polyhedron
  22805. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22806. * * type provided types are:
  22807. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22808. * * 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)
  22809. * * size the size of the IcoSphere, optional default 1
  22810. * * sizeX allows stretching in the x direction, optional, default size
  22811. * * sizeY allows stretching in the y direction, optional, default size
  22812. * * sizeZ allows stretching in the z direction, optional, default size
  22813. * * 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
  22814. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22815. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22816. * * flat when true creates a flat shaded mesh, optional, default true
  22817. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22819. * * 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)
  22820. * * 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)
  22821. * @returns the VertexData of the Polyhedron
  22822. */
  22823. static CreatePolyhedron(options: {
  22824. type?: number;
  22825. size?: number;
  22826. sizeX?: number;
  22827. sizeY?: number;
  22828. sizeZ?: number;
  22829. custom?: any;
  22830. faceUV?: Vector4[];
  22831. faceColors?: Color4[];
  22832. flat?: boolean;
  22833. sideOrientation?: number;
  22834. frontUVs?: Vector4;
  22835. backUVs?: Vector4;
  22836. }): VertexData;
  22837. /**
  22838. * Creates the VertexData for a TorusKnot
  22839. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22840. * * radius the radius of the torus knot, optional, default 2
  22841. * * tube the thickness of the tube, optional, default 0.5
  22842. * * radialSegments the number of sides on each tube segments, optional, default 32
  22843. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22844. * * p the number of windings around the z axis, optional, default 2
  22845. * * q the number of windings around the x axis, optional, default 3
  22846. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22847. * * 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)
  22848. * * 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)
  22849. * @returns the VertexData of the Torus Knot
  22850. */
  22851. static CreateTorusKnot(options: {
  22852. radius?: number;
  22853. tube?: number;
  22854. radialSegments?: number;
  22855. tubularSegments?: number;
  22856. p?: number;
  22857. q?: number;
  22858. sideOrientation?: number;
  22859. frontUVs?: Vector4;
  22860. backUVs?: Vector4;
  22861. }): VertexData;
  22862. /**
  22863. * Compute normals for given positions and indices
  22864. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22865. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22866. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22867. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22868. * * facetNormals : optional array of facet normals (vector3)
  22869. * * facetPositions : optional array of facet positions (vector3)
  22870. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22871. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22872. * * bInfo : optional bounding info, required for facetPartitioning computation
  22873. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22874. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22875. * * useRightHandedSystem: optional boolean to for right handed system computation
  22876. * * depthSort : optional boolean to enable the facet depth sort computation
  22877. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22878. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22879. */
  22880. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22881. facetNormals?: any;
  22882. facetPositions?: any;
  22883. facetPartitioning?: any;
  22884. ratio?: number;
  22885. bInfo?: any;
  22886. bbSize?: Vector3;
  22887. subDiv?: any;
  22888. useRightHandedSystem?: boolean;
  22889. depthSort?: boolean;
  22890. distanceTo?: Vector3;
  22891. depthSortedFacets?: any;
  22892. }): void;
  22893. /** @hidden */
  22894. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22895. /**
  22896. * Applies VertexData created from the imported parameters to the geometry
  22897. * @param parsedVertexData the parsed data from an imported file
  22898. * @param geometry the geometry to apply the VertexData to
  22899. */
  22900. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22901. }
  22902. }
  22903. declare module BABYLON {
  22904. /**
  22905. * Defines a target to use with MorphTargetManager
  22906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22907. */
  22908. export class MorphTarget implements IAnimatable {
  22909. /** defines the name of the target */
  22910. name: string;
  22911. /**
  22912. * Gets or sets the list of animations
  22913. */
  22914. animations: Animation[];
  22915. private _scene;
  22916. private _positions;
  22917. private _normals;
  22918. private _tangents;
  22919. private _uvs;
  22920. private _influence;
  22921. private _uniqueId;
  22922. /**
  22923. * Observable raised when the influence changes
  22924. */
  22925. onInfluenceChanged: Observable<boolean>;
  22926. /** @hidden */
  22927. _onDataLayoutChanged: Observable<void>;
  22928. /**
  22929. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22930. */
  22931. get influence(): number;
  22932. set influence(influence: number);
  22933. /**
  22934. * Gets or sets the id of the morph Target
  22935. */
  22936. id: string;
  22937. private _animationPropertiesOverride;
  22938. /**
  22939. * Gets or sets the animation properties override
  22940. */
  22941. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22942. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22943. /**
  22944. * Creates a new MorphTarget
  22945. * @param name defines the name of the target
  22946. * @param influence defines the influence to use
  22947. * @param scene defines the scene the morphtarget belongs to
  22948. */
  22949. constructor(
  22950. /** defines the name of the target */
  22951. name: string, influence?: number, scene?: Nullable<Scene>);
  22952. /**
  22953. * Gets the unique ID of this manager
  22954. */
  22955. get uniqueId(): number;
  22956. /**
  22957. * Gets a boolean defining if the target contains position data
  22958. */
  22959. get hasPositions(): boolean;
  22960. /**
  22961. * Gets a boolean defining if the target contains normal data
  22962. */
  22963. get hasNormals(): boolean;
  22964. /**
  22965. * Gets a boolean defining if the target contains tangent data
  22966. */
  22967. get hasTangents(): boolean;
  22968. /**
  22969. * Gets a boolean defining if the target contains texture coordinates data
  22970. */
  22971. get hasUVs(): boolean;
  22972. /**
  22973. * Affects position data to this target
  22974. * @param data defines the position data to use
  22975. */
  22976. setPositions(data: Nullable<FloatArray>): void;
  22977. /**
  22978. * Gets the position data stored in this target
  22979. * @returns a FloatArray containing the position data (or null if not present)
  22980. */
  22981. getPositions(): Nullable<FloatArray>;
  22982. /**
  22983. * Affects normal data to this target
  22984. * @param data defines the normal data to use
  22985. */
  22986. setNormals(data: Nullable<FloatArray>): void;
  22987. /**
  22988. * Gets the normal data stored in this target
  22989. * @returns a FloatArray containing the normal data (or null if not present)
  22990. */
  22991. getNormals(): Nullable<FloatArray>;
  22992. /**
  22993. * Affects tangent data to this target
  22994. * @param data defines the tangent data to use
  22995. */
  22996. setTangents(data: Nullable<FloatArray>): void;
  22997. /**
  22998. * Gets the tangent data stored in this target
  22999. * @returns a FloatArray containing the tangent data (or null if not present)
  23000. */
  23001. getTangents(): Nullable<FloatArray>;
  23002. /**
  23003. * Affects texture coordinates data to this target
  23004. * @param data defines the texture coordinates data to use
  23005. */
  23006. setUVs(data: Nullable<FloatArray>): void;
  23007. /**
  23008. * Gets the texture coordinates data stored in this target
  23009. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23010. */
  23011. getUVs(): Nullable<FloatArray>;
  23012. /**
  23013. * Clone the current target
  23014. * @returns a new MorphTarget
  23015. */
  23016. clone(): MorphTarget;
  23017. /**
  23018. * Serializes the current target into a Serialization object
  23019. * @returns the serialized object
  23020. */
  23021. serialize(): any;
  23022. /**
  23023. * Returns the string "MorphTarget"
  23024. * @returns "MorphTarget"
  23025. */
  23026. getClassName(): string;
  23027. /**
  23028. * Creates a new target from serialized data
  23029. * @param serializationObject defines the serialized data to use
  23030. * @returns a new MorphTarget
  23031. */
  23032. static Parse(serializationObject: any): MorphTarget;
  23033. /**
  23034. * Creates a MorphTarget from mesh data
  23035. * @param mesh defines the source mesh
  23036. * @param name defines the name to use for the new target
  23037. * @param influence defines the influence to attach to the target
  23038. * @returns a new MorphTarget
  23039. */
  23040. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23041. }
  23042. }
  23043. declare module BABYLON {
  23044. /**
  23045. * This class is used to deform meshes using morphing between different targets
  23046. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23047. */
  23048. export class MorphTargetManager {
  23049. private _targets;
  23050. private _targetInfluenceChangedObservers;
  23051. private _targetDataLayoutChangedObservers;
  23052. private _activeTargets;
  23053. private _scene;
  23054. private _influences;
  23055. private _supportsNormals;
  23056. private _supportsTangents;
  23057. private _supportsUVs;
  23058. private _vertexCount;
  23059. private _uniqueId;
  23060. private _tempInfluences;
  23061. /**
  23062. * Gets or sets a boolean indicating if normals must be morphed
  23063. */
  23064. enableNormalMorphing: boolean;
  23065. /**
  23066. * Gets or sets a boolean indicating if tangents must be morphed
  23067. */
  23068. enableTangentMorphing: boolean;
  23069. /**
  23070. * Gets or sets a boolean indicating if UV must be morphed
  23071. */
  23072. enableUVMorphing: boolean;
  23073. /**
  23074. * Creates a new MorphTargetManager
  23075. * @param scene defines the current scene
  23076. */
  23077. constructor(scene?: Nullable<Scene>);
  23078. /**
  23079. * Gets the unique ID of this manager
  23080. */
  23081. get uniqueId(): number;
  23082. /**
  23083. * Gets the number of vertices handled by this manager
  23084. */
  23085. get vertexCount(): number;
  23086. /**
  23087. * Gets a boolean indicating if this manager supports morphing of normals
  23088. */
  23089. get supportsNormals(): boolean;
  23090. /**
  23091. * Gets a boolean indicating if this manager supports morphing of tangents
  23092. */
  23093. get supportsTangents(): boolean;
  23094. /**
  23095. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23096. */
  23097. get supportsUVs(): boolean;
  23098. /**
  23099. * Gets the number of targets stored in this manager
  23100. */
  23101. get numTargets(): number;
  23102. /**
  23103. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23104. */
  23105. get numInfluencers(): number;
  23106. /**
  23107. * Gets the list of influences (one per target)
  23108. */
  23109. get influences(): Float32Array;
  23110. /**
  23111. * Gets the active target at specified index. An active target is a target with an influence > 0
  23112. * @param index defines the index to check
  23113. * @returns the requested target
  23114. */
  23115. getActiveTarget(index: number): MorphTarget;
  23116. /**
  23117. * Gets the target at specified index
  23118. * @param index defines the index to check
  23119. * @returns the requested target
  23120. */
  23121. getTarget(index: number): MorphTarget;
  23122. /**
  23123. * Add a new target to this manager
  23124. * @param target defines the target to add
  23125. */
  23126. addTarget(target: MorphTarget): void;
  23127. /**
  23128. * Removes a target from the manager
  23129. * @param target defines the target to remove
  23130. */
  23131. removeTarget(target: MorphTarget): void;
  23132. /**
  23133. * Clone the current manager
  23134. * @returns a new MorphTargetManager
  23135. */
  23136. clone(): MorphTargetManager;
  23137. /**
  23138. * Serializes the current manager into a Serialization object
  23139. * @returns the serialized object
  23140. */
  23141. serialize(): any;
  23142. private _syncActiveTargets;
  23143. /**
  23144. * Syncrhonize the targets with all the meshes using this morph target manager
  23145. */
  23146. synchronize(): void;
  23147. /**
  23148. * Creates a new MorphTargetManager from serialized data
  23149. * @param serializationObject defines the serialized data
  23150. * @param scene defines the hosting scene
  23151. * @returns the new MorphTargetManager
  23152. */
  23153. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23154. }
  23155. }
  23156. declare module BABYLON {
  23157. /**
  23158. * Class used to represent a specific level of detail of a mesh
  23159. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23160. */
  23161. export class MeshLODLevel {
  23162. /** Defines the distance where this level should start being displayed */
  23163. distance: number;
  23164. /** Defines the mesh to use to render this level */
  23165. mesh: Nullable<Mesh>;
  23166. /**
  23167. * Creates a new LOD level
  23168. * @param distance defines the distance where this level should star being displayed
  23169. * @param mesh defines the mesh to use to render this level
  23170. */
  23171. constructor(
  23172. /** Defines the distance where this level should start being displayed */
  23173. distance: number,
  23174. /** Defines the mesh to use to render this level */
  23175. mesh: Nullable<Mesh>);
  23176. }
  23177. }
  23178. declare module BABYLON {
  23179. /**
  23180. * Mesh representing the gorund
  23181. */
  23182. export class GroundMesh extends Mesh {
  23183. /** If octree should be generated */
  23184. generateOctree: boolean;
  23185. private _heightQuads;
  23186. /** @hidden */
  23187. _subdivisionsX: number;
  23188. /** @hidden */
  23189. _subdivisionsY: number;
  23190. /** @hidden */
  23191. _width: number;
  23192. /** @hidden */
  23193. _height: number;
  23194. /** @hidden */
  23195. _minX: number;
  23196. /** @hidden */
  23197. _maxX: number;
  23198. /** @hidden */
  23199. _minZ: number;
  23200. /** @hidden */
  23201. _maxZ: number;
  23202. constructor(name: string, scene: Scene);
  23203. /**
  23204. * "GroundMesh"
  23205. * @returns "GroundMesh"
  23206. */
  23207. getClassName(): string;
  23208. /**
  23209. * The minimum of x and y subdivisions
  23210. */
  23211. get subdivisions(): number;
  23212. /**
  23213. * X subdivisions
  23214. */
  23215. get subdivisionsX(): number;
  23216. /**
  23217. * Y subdivisions
  23218. */
  23219. get subdivisionsY(): number;
  23220. /**
  23221. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23222. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23223. * @param chunksCount the number of subdivisions for x and y
  23224. * @param octreeBlocksSize (Default: 32)
  23225. */
  23226. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23227. /**
  23228. * Returns a height (y) value in the Worl system :
  23229. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23230. * @param x x coordinate
  23231. * @param z z coordinate
  23232. * @returns the ground y position if (x, z) are outside the ground surface.
  23233. */
  23234. getHeightAtCoordinates(x: number, z: number): number;
  23235. /**
  23236. * Returns a normalized vector (Vector3) orthogonal to the ground
  23237. * at the ground coordinates (x, z) expressed in the World system.
  23238. * @param x x coordinate
  23239. * @param z z coordinate
  23240. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23241. */
  23242. getNormalAtCoordinates(x: number, z: number): Vector3;
  23243. /**
  23244. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23245. * at the ground coordinates (x, z) expressed in the World system.
  23246. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23247. * @param x x coordinate
  23248. * @param z z coordinate
  23249. * @param ref vector to store the result
  23250. * @returns the GroundMesh.
  23251. */
  23252. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23253. /**
  23254. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23255. * if the ground has been updated.
  23256. * This can be used in the render loop.
  23257. * @returns the GroundMesh.
  23258. */
  23259. updateCoordinateHeights(): GroundMesh;
  23260. private _getFacetAt;
  23261. private _initHeightQuads;
  23262. private _computeHeightQuads;
  23263. /**
  23264. * Serializes this ground mesh
  23265. * @param serializationObject object to write serialization to
  23266. */
  23267. serialize(serializationObject: any): void;
  23268. /**
  23269. * Parses a serialized ground mesh
  23270. * @param parsedMesh the serialized mesh
  23271. * @param scene the scene to create the ground mesh in
  23272. * @returns the created ground mesh
  23273. */
  23274. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23275. }
  23276. }
  23277. declare module BABYLON {
  23278. /**
  23279. * Interface for Physics-Joint data
  23280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23281. */
  23282. export interface PhysicsJointData {
  23283. /**
  23284. * The main pivot of the joint
  23285. */
  23286. mainPivot?: Vector3;
  23287. /**
  23288. * The connected pivot of the joint
  23289. */
  23290. connectedPivot?: Vector3;
  23291. /**
  23292. * The main axis of the joint
  23293. */
  23294. mainAxis?: Vector3;
  23295. /**
  23296. * The connected axis of the joint
  23297. */
  23298. connectedAxis?: Vector3;
  23299. /**
  23300. * The collision of the joint
  23301. */
  23302. collision?: boolean;
  23303. /**
  23304. * Native Oimo/Cannon/Energy data
  23305. */
  23306. nativeParams?: any;
  23307. }
  23308. /**
  23309. * This is a holder class for the physics joint created by the physics plugin
  23310. * It holds a set of functions to control the underlying joint
  23311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23312. */
  23313. export class PhysicsJoint {
  23314. /**
  23315. * The type of the physics joint
  23316. */
  23317. type: number;
  23318. /**
  23319. * The data for the physics joint
  23320. */
  23321. jointData: PhysicsJointData;
  23322. private _physicsJoint;
  23323. protected _physicsPlugin: IPhysicsEnginePlugin;
  23324. /**
  23325. * Initializes the physics joint
  23326. * @param type The type of the physics joint
  23327. * @param jointData The data for the physics joint
  23328. */
  23329. constructor(
  23330. /**
  23331. * The type of the physics joint
  23332. */
  23333. type: number,
  23334. /**
  23335. * The data for the physics joint
  23336. */
  23337. jointData: PhysicsJointData);
  23338. /**
  23339. * Gets the physics joint
  23340. */
  23341. get physicsJoint(): any;
  23342. /**
  23343. * Sets the physics joint
  23344. */
  23345. set physicsJoint(newJoint: any);
  23346. /**
  23347. * Sets the physics plugin
  23348. */
  23349. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23350. /**
  23351. * Execute a function that is physics-plugin specific.
  23352. * @param {Function} func the function that will be executed.
  23353. * It accepts two parameters: the physics world and the physics joint
  23354. */
  23355. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23356. /**
  23357. * Distance-Joint type
  23358. */
  23359. static DistanceJoint: number;
  23360. /**
  23361. * Hinge-Joint type
  23362. */
  23363. static HingeJoint: number;
  23364. /**
  23365. * Ball-and-Socket joint type
  23366. */
  23367. static BallAndSocketJoint: number;
  23368. /**
  23369. * Wheel-Joint type
  23370. */
  23371. static WheelJoint: number;
  23372. /**
  23373. * Slider-Joint type
  23374. */
  23375. static SliderJoint: number;
  23376. /**
  23377. * Prismatic-Joint type
  23378. */
  23379. static PrismaticJoint: number;
  23380. /**
  23381. * Universal-Joint type
  23382. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23383. */
  23384. static UniversalJoint: number;
  23385. /**
  23386. * Hinge-Joint 2 type
  23387. */
  23388. static Hinge2Joint: number;
  23389. /**
  23390. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23391. */
  23392. static PointToPointJoint: number;
  23393. /**
  23394. * Spring-Joint type
  23395. */
  23396. static SpringJoint: number;
  23397. /**
  23398. * Lock-Joint type
  23399. */
  23400. static LockJoint: number;
  23401. }
  23402. /**
  23403. * A class representing a physics distance joint
  23404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23405. */
  23406. export class DistanceJoint extends PhysicsJoint {
  23407. /**
  23408. *
  23409. * @param jointData The data for the Distance-Joint
  23410. */
  23411. constructor(jointData: DistanceJointData);
  23412. /**
  23413. * Update the predefined distance.
  23414. * @param maxDistance The maximum preferred distance
  23415. * @param minDistance The minimum preferred distance
  23416. */
  23417. updateDistance(maxDistance: number, minDistance?: number): void;
  23418. }
  23419. /**
  23420. * Represents a Motor-Enabled Joint
  23421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23422. */
  23423. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23424. /**
  23425. * Initializes the Motor-Enabled Joint
  23426. * @param type The type of the joint
  23427. * @param jointData The physica joint data for the joint
  23428. */
  23429. constructor(type: number, jointData: PhysicsJointData);
  23430. /**
  23431. * Set the motor values.
  23432. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23433. * @param force the force to apply
  23434. * @param maxForce max force for this motor.
  23435. */
  23436. setMotor(force?: number, maxForce?: number): void;
  23437. /**
  23438. * Set the motor's limits.
  23439. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23440. * @param upperLimit The upper limit of the motor
  23441. * @param lowerLimit The lower limit of the motor
  23442. */
  23443. setLimit(upperLimit: number, lowerLimit?: number): void;
  23444. }
  23445. /**
  23446. * This class represents a single physics Hinge-Joint
  23447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23448. */
  23449. export class HingeJoint extends MotorEnabledJoint {
  23450. /**
  23451. * Initializes the Hinge-Joint
  23452. * @param jointData The joint data for the Hinge-Joint
  23453. */
  23454. constructor(jointData: PhysicsJointData);
  23455. /**
  23456. * Set the motor values.
  23457. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23458. * @param {number} force the force to apply
  23459. * @param {number} maxForce max force for this motor.
  23460. */
  23461. setMotor(force?: number, maxForce?: number): void;
  23462. /**
  23463. * Set the motor's limits.
  23464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23465. * @param upperLimit The upper limit of the motor
  23466. * @param lowerLimit The lower limit of the motor
  23467. */
  23468. setLimit(upperLimit: number, lowerLimit?: number): void;
  23469. }
  23470. /**
  23471. * This class represents a dual hinge physics joint (same as wheel joint)
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export class Hinge2Joint extends MotorEnabledJoint {
  23475. /**
  23476. * Initializes the Hinge2-Joint
  23477. * @param jointData The joint data for the Hinge2-Joint
  23478. */
  23479. constructor(jointData: PhysicsJointData);
  23480. /**
  23481. * Set the motor values.
  23482. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23483. * @param {number} targetSpeed the speed the motor is to reach
  23484. * @param {number} maxForce max force for this motor.
  23485. * @param {motorIndex} the motor's index, 0 or 1.
  23486. */
  23487. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23488. /**
  23489. * Set the motor limits.
  23490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23491. * @param {number} upperLimit the upper limit
  23492. * @param {number} lowerLimit lower limit
  23493. * @param {motorIndex} the motor's index, 0 or 1.
  23494. */
  23495. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23496. }
  23497. /**
  23498. * Interface for a motor enabled joint
  23499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23500. */
  23501. export interface IMotorEnabledJoint {
  23502. /**
  23503. * Physics joint
  23504. */
  23505. physicsJoint: any;
  23506. /**
  23507. * Sets the motor of the motor-enabled joint
  23508. * @param force The force of the motor
  23509. * @param maxForce The maximum force of the motor
  23510. * @param motorIndex The index of the motor
  23511. */
  23512. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23513. /**
  23514. * Sets the limit of the motor
  23515. * @param upperLimit The upper limit of the motor
  23516. * @param lowerLimit The lower limit of the motor
  23517. * @param motorIndex The index of the motor
  23518. */
  23519. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23520. }
  23521. /**
  23522. * Joint data for a Distance-Joint
  23523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export interface DistanceJointData extends PhysicsJointData {
  23526. /**
  23527. * Max distance the 2 joint objects can be apart
  23528. */
  23529. maxDistance: number;
  23530. }
  23531. /**
  23532. * Joint data from a spring joint
  23533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23534. */
  23535. export interface SpringJointData extends PhysicsJointData {
  23536. /**
  23537. * Length of the spring
  23538. */
  23539. length: number;
  23540. /**
  23541. * Stiffness of the spring
  23542. */
  23543. stiffness: number;
  23544. /**
  23545. * Damping of the spring
  23546. */
  23547. damping: number;
  23548. /** this callback will be called when applying the force to the impostors. */
  23549. forceApplicationCallback: () => void;
  23550. }
  23551. }
  23552. declare module BABYLON {
  23553. /**
  23554. * Holds the data for the raycast result
  23555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23556. */
  23557. export class PhysicsRaycastResult {
  23558. private _hasHit;
  23559. private _hitDistance;
  23560. private _hitNormalWorld;
  23561. private _hitPointWorld;
  23562. private _rayFromWorld;
  23563. private _rayToWorld;
  23564. /**
  23565. * Gets if there was a hit
  23566. */
  23567. get hasHit(): boolean;
  23568. /**
  23569. * Gets the distance from the hit
  23570. */
  23571. get hitDistance(): number;
  23572. /**
  23573. * Gets the hit normal/direction in the world
  23574. */
  23575. get hitNormalWorld(): Vector3;
  23576. /**
  23577. * Gets the hit point in the world
  23578. */
  23579. get hitPointWorld(): Vector3;
  23580. /**
  23581. * Gets the ray "start point" of the ray in the world
  23582. */
  23583. get rayFromWorld(): Vector3;
  23584. /**
  23585. * Gets the ray "end point" of the ray in the world
  23586. */
  23587. get rayToWorld(): Vector3;
  23588. /**
  23589. * Sets the hit data (normal & point in world space)
  23590. * @param hitNormalWorld defines the normal in world space
  23591. * @param hitPointWorld defines the point in world space
  23592. */
  23593. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23594. /**
  23595. * Sets the distance from the start point to the hit point
  23596. * @param distance
  23597. */
  23598. setHitDistance(distance: number): void;
  23599. /**
  23600. * Calculates the distance manually
  23601. */
  23602. calculateHitDistance(): void;
  23603. /**
  23604. * Resets all the values to default
  23605. * @param from The from point on world space
  23606. * @param to The to point on world space
  23607. */
  23608. reset(from?: Vector3, to?: Vector3): void;
  23609. }
  23610. /**
  23611. * Interface for the size containing width and height
  23612. */
  23613. interface IXYZ {
  23614. /**
  23615. * X
  23616. */
  23617. x: number;
  23618. /**
  23619. * Y
  23620. */
  23621. y: number;
  23622. /**
  23623. * Z
  23624. */
  23625. z: number;
  23626. }
  23627. }
  23628. declare module BABYLON {
  23629. /**
  23630. * Interface used to describe a physics joint
  23631. */
  23632. export interface PhysicsImpostorJoint {
  23633. /** Defines the main impostor to which the joint is linked */
  23634. mainImpostor: PhysicsImpostor;
  23635. /** Defines the impostor that is connected to the main impostor using this joint */
  23636. connectedImpostor: PhysicsImpostor;
  23637. /** Defines the joint itself */
  23638. joint: PhysicsJoint;
  23639. }
  23640. /** @hidden */
  23641. export interface IPhysicsEnginePlugin {
  23642. world: any;
  23643. name: string;
  23644. setGravity(gravity: Vector3): void;
  23645. setTimeStep(timeStep: number): void;
  23646. getTimeStep(): number;
  23647. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23651. removePhysicsBody(impostor: PhysicsImpostor): void;
  23652. generateJoint(joint: PhysicsImpostorJoint): void;
  23653. removeJoint(joint: PhysicsImpostorJoint): void;
  23654. isSupported(): boolean;
  23655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23657. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23659. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23662. getBodyMass(impostor: PhysicsImpostor): number;
  23663. getBodyFriction(impostor: PhysicsImpostor): number;
  23664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23665. getBodyRestitution(impostor: PhysicsImpostor): number;
  23666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23667. getBodyPressure?(impostor: PhysicsImpostor): number;
  23668. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23669. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23670. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23671. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23672. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23673. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23674. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23675. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23676. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23677. sleepBody(impostor: PhysicsImpostor): void;
  23678. wakeUpBody(impostor: PhysicsImpostor): void;
  23679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23680. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23681. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23682. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23683. getRadius(impostor: PhysicsImpostor): number;
  23684. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23685. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23686. dispose(): void;
  23687. }
  23688. /**
  23689. * Interface used to define a physics engine
  23690. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23691. */
  23692. export interface IPhysicsEngine {
  23693. /**
  23694. * Gets the gravity vector used by the simulation
  23695. */
  23696. gravity: Vector3;
  23697. /**
  23698. * Sets the gravity vector used by the simulation
  23699. * @param gravity defines the gravity vector to use
  23700. */
  23701. setGravity(gravity: Vector3): void;
  23702. /**
  23703. * Set the time step of the physics engine.
  23704. * Default is 1/60.
  23705. * To slow it down, enter 1/600 for example.
  23706. * To speed it up, 1/30
  23707. * @param newTimeStep the new timestep to apply to this world.
  23708. */
  23709. setTimeStep(newTimeStep: number): void;
  23710. /**
  23711. * Get the time step of the physics engine.
  23712. * @returns the current time step
  23713. */
  23714. getTimeStep(): number;
  23715. /**
  23716. * Set the sub time step of the physics engine.
  23717. * Default is 0 meaning there is no sub steps
  23718. * To increase physics resolution precision, set a small value (like 1 ms)
  23719. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23720. */
  23721. setSubTimeStep(subTimeStep: number): void;
  23722. /**
  23723. * Get the sub time step of the physics engine.
  23724. * @returns the current sub time step
  23725. */
  23726. getSubTimeStep(): number;
  23727. /**
  23728. * Release all resources
  23729. */
  23730. dispose(): void;
  23731. /**
  23732. * Gets the name of the current physics plugin
  23733. * @returns the name of the plugin
  23734. */
  23735. getPhysicsPluginName(): string;
  23736. /**
  23737. * Adding a new impostor for the impostor tracking.
  23738. * This will be done by the impostor itself.
  23739. * @param impostor the impostor to add
  23740. */
  23741. addImpostor(impostor: PhysicsImpostor): void;
  23742. /**
  23743. * Remove an impostor from the engine.
  23744. * This impostor and its mesh will not longer be updated by the physics engine.
  23745. * @param impostor the impostor to remove
  23746. */
  23747. removeImpostor(impostor: PhysicsImpostor): void;
  23748. /**
  23749. * Add a joint to the physics engine
  23750. * @param mainImpostor defines the main impostor to which the joint is added.
  23751. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23752. * @param joint defines the joint that will connect both impostors.
  23753. */
  23754. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23755. /**
  23756. * Removes a joint from the simulation
  23757. * @param mainImpostor defines the impostor used with the joint
  23758. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23759. * @param joint defines the joint to remove
  23760. */
  23761. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23762. /**
  23763. * Gets the current plugin used to run the simulation
  23764. * @returns current plugin
  23765. */
  23766. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23767. /**
  23768. * Gets the list of physic impostors
  23769. * @returns an array of PhysicsImpostor
  23770. */
  23771. getImpostors(): Array<PhysicsImpostor>;
  23772. /**
  23773. * Gets the impostor for a physics enabled object
  23774. * @param object defines the object impersonated by the impostor
  23775. * @returns the PhysicsImpostor or null if not found
  23776. */
  23777. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23778. /**
  23779. * Gets the impostor for a physics body object
  23780. * @param body defines physics body used by the impostor
  23781. * @returns the PhysicsImpostor or null if not found
  23782. */
  23783. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23784. /**
  23785. * Does a raycast in the physics world
  23786. * @param from when should the ray start?
  23787. * @param to when should the ray end?
  23788. * @returns PhysicsRaycastResult
  23789. */
  23790. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23791. /**
  23792. * Called by the scene. No need to call it.
  23793. * @param delta defines the timespam between frames
  23794. */
  23795. _step(delta: number): void;
  23796. }
  23797. }
  23798. declare module BABYLON {
  23799. /**
  23800. * The interface for the physics imposter parameters
  23801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23802. */
  23803. export interface PhysicsImpostorParameters {
  23804. /**
  23805. * The mass of the physics imposter
  23806. */
  23807. mass: number;
  23808. /**
  23809. * The friction of the physics imposter
  23810. */
  23811. friction?: number;
  23812. /**
  23813. * The coefficient of restitution of the physics imposter
  23814. */
  23815. restitution?: number;
  23816. /**
  23817. * The native options of the physics imposter
  23818. */
  23819. nativeOptions?: any;
  23820. /**
  23821. * Specifies if the parent should be ignored
  23822. */
  23823. ignoreParent?: boolean;
  23824. /**
  23825. * Specifies if bi-directional transformations should be disabled
  23826. */
  23827. disableBidirectionalTransformation?: boolean;
  23828. /**
  23829. * The pressure inside the physics imposter, soft object only
  23830. */
  23831. pressure?: number;
  23832. /**
  23833. * The stiffness the physics imposter, soft object only
  23834. */
  23835. stiffness?: number;
  23836. /**
  23837. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23838. */
  23839. velocityIterations?: number;
  23840. /**
  23841. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23842. */
  23843. positionIterations?: number;
  23844. /**
  23845. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23846. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23847. * Add to fix multiple points
  23848. */
  23849. fixedPoints?: number;
  23850. /**
  23851. * The collision margin around a soft object
  23852. */
  23853. margin?: number;
  23854. /**
  23855. * The collision margin around a soft object
  23856. */
  23857. damping?: number;
  23858. /**
  23859. * The path for a rope based on an extrusion
  23860. */
  23861. path?: any;
  23862. /**
  23863. * The shape of an extrusion used for a rope based on an extrusion
  23864. */
  23865. shape?: any;
  23866. }
  23867. /**
  23868. * Interface for a physics-enabled object
  23869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23870. */
  23871. export interface IPhysicsEnabledObject {
  23872. /**
  23873. * The position of the physics-enabled object
  23874. */
  23875. position: Vector3;
  23876. /**
  23877. * The rotation of the physics-enabled object
  23878. */
  23879. rotationQuaternion: Nullable<Quaternion>;
  23880. /**
  23881. * The scale of the physics-enabled object
  23882. */
  23883. scaling: Vector3;
  23884. /**
  23885. * The rotation of the physics-enabled object
  23886. */
  23887. rotation?: Vector3;
  23888. /**
  23889. * The parent of the physics-enabled object
  23890. */
  23891. parent?: any;
  23892. /**
  23893. * The bounding info of the physics-enabled object
  23894. * @returns The bounding info of the physics-enabled object
  23895. */
  23896. getBoundingInfo(): BoundingInfo;
  23897. /**
  23898. * Computes the world matrix
  23899. * @param force Specifies if the world matrix should be computed by force
  23900. * @returns A world matrix
  23901. */
  23902. computeWorldMatrix(force: boolean): Matrix;
  23903. /**
  23904. * Gets the world matrix
  23905. * @returns A world matrix
  23906. */
  23907. getWorldMatrix?(): Matrix;
  23908. /**
  23909. * Gets the child meshes
  23910. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23911. * @returns An array of abstract meshes
  23912. */
  23913. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23914. /**
  23915. * Gets the vertex data
  23916. * @param kind The type of vertex data
  23917. * @returns A nullable array of numbers, or a float32 array
  23918. */
  23919. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23920. /**
  23921. * Gets the indices from the mesh
  23922. * @returns A nullable array of index arrays
  23923. */
  23924. getIndices?(): Nullable<IndicesArray>;
  23925. /**
  23926. * Gets the scene from the mesh
  23927. * @returns the indices array or null
  23928. */
  23929. getScene?(): Scene;
  23930. /**
  23931. * Gets the absolute position from the mesh
  23932. * @returns the absolute position
  23933. */
  23934. getAbsolutePosition(): Vector3;
  23935. /**
  23936. * Gets the absolute pivot point from the mesh
  23937. * @returns the absolute pivot point
  23938. */
  23939. getAbsolutePivotPoint(): Vector3;
  23940. /**
  23941. * Rotates the mesh
  23942. * @param axis The axis of rotation
  23943. * @param amount The amount of rotation
  23944. * @param space The space of the rotation
  23945. * @returns The rotation transform node
  23946. */
  23947. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23948. /**
  23949. * Translates the mesh
  23950. * @param axis The axis of translation
  23951. * @param distance The distance of translation
  23952. * @param space The space of the translation
  23953. * @returns The transform node
  23954. */
  23955. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23956. /**
  23957. * Sets the absolute position of the mesh
  23958. * @param absolutePosition The absolute position of the mesh
  23959. * @returns The transform node
  23960. */
  23961. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23962. /**
  23963. * Gets the class name of the mesh
  23964. * @returns The class name
  23965. */
  23966. getClassName(): string;
  23967. }
  23968. /**
  23969. * Represents a physics imposter
  23970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23971. */
  23972. export class PhysicsImpostor {
  23973. /**
  23974. * The physics-enabled object used as the physics imposter
  23975. */
  23976. object: IPhysicsEnabledObject;
  23977. /**
  23978. * The type of the physics imposter
  23979. */
  23980. type: number;
  23981. private _options;
  23982. private _scene?;
  23983. /**
  23984. * The default object size of the imposter
  23985. */
  23986. static DEFAULT_OBJECT_SIZE: Vector3;
  23987. /**
  23988. * The identity quaternion of the imposter
  23989. */
  23990. static IDENTITY_QUATERNION: Quaternion;
  23991. /** @hidden */
  23992. _pluginData: any;
  23993. private _physicsEngine;
  23994. private _physicsBody;
  23995. private _bodyUpdateRequired;
  23996. private _onBeforePhysicsStepCallbacks;
  23997. private _onAfterPhysicsStepCallbacks;
  23998. /** @hidden */
  23999. _onPhysicsCollideCallbacks: Array<{
  24000. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24001. otherImpostors: Array<PhysicsImpostor>;
  24002. }>;
  24003. private _deltaPosition;
  24004. private _deltaRotation;
  24005. private _deltaRotationConjugated;
  24006. /** @hidden */
  24007. _isFromLine: boolean;
  24008. private _parent;
  24009. private _isDisposed;
  24010. private static _tmpVecs;
  24011. private static _tmpQuat;
  24012. /**
  24013. * Specifies if the physics imposter is disposed
  24014. */
  24015. get isDisposed(): boolean;
  24016. /**
  24017. * Gets the mass of the physics imposter
  24018. */
  24019. get mass(): number;
  24020. set mass(value: number);
  24021. /**
  24022. * Gets the coefficient of friction
  24023. */
  24024. get friction(): number;
  24025. /**
  24026. * Sets the coefficient of friction
  24027. */
  24028. set friction(value: number);
  24029. /**
  24030. * Gets the coefficient of restitution
  24031. */
  24032. get restitution(): number;
  24033. /**
  24034. * Sets the coefficient of restitution
  24035. */
  24036. set restitution(value: number);
  24037. /**
  24038. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24039. */
  24040. get pressure(): number;
  24041. /**
  24042. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24043. */
  24044. set pressure(value: number);
  24045. /**
  24046. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24047. */
  24048. get stiffness(): number;
  24049. /**
  24050. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24051. */
  24052. set stiffness(value: number);
  24053. /**
  24054. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24055. */
  24056. get velocityIterations(): number;
  24057. /**
  24058. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24059. */
  24060. set velocityIterations(value: number);
  24061. /**
  24062. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24063. */
  24064. get positionIterations(): number;
  24065. /**
  24066. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24067. */
  24068. set positionIterations(value: number);
  24069. /**
  24070. * The unique id of the physics imposter
  24071. * set by the physics engine when adding this impostor to the array
  24072. */
  24073. uniqueId: number;
  24074. /**
  24075. * @hidden
  24076. */
  24077. soft: boolean;
  24078. /**
  24079. * @hidden
  24080. */
  24081. segments: number;
  24082. private _joints;
  24083. /**
  24084. * Initializes the physics imposter
  24085. * @param object The physics-enabled object used as the physics imposter
  24086. * @param type The type of the physics imposter
  24087. * @param _options The options for the physics imposter
  24088. * @param _scene The Babylon scene
  24089. */
  24090. constructor(
  24091. /**
  24092. * The physics-enabled object used as the physics imposter
  24093. */
  24094. object: IPhysicsEnabledObject,
  24095. /**
  24096. * The type of the physics imposter
  24097. */
  24098. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24099. /**
  24100. * This function will completly initialize this impostor.
  24101. * It will create a new body - but only if this mesh has no parent.
  24102. * If it has, this impostor will not be used other than to define the impostor
  24103. * of the child mesh.
  24104. * @hidden
  24105. */
  24106. _init(): void;
  24107. private _getPhysicsParent;
  24108. /**
  24109. * Should a new body be generated.
  24110. * @returns boolean specifying if body initialization is required
  24111. */
  24112. isBodyInitRequired(): boolean;
  24113. /**
  24114. * Sets the updated scaling
  24115. * @param updated Specifies if the scaling is updated
  24116. */
  24117. setScalingUpdated(): void;
  24118. /**
  24119. * Force a regeneration of this or the parent's impostor's body.
  24120. * Use under cautious - This will remove all joints already implemented.
  24121. */
  24122. forceUpdate(): void;
  24123. /**
  24124. * Gets the body that holds this impostor. Either its own, or its parent.
  24125. */
  24126. get physicsBody(): any;
  24127. /**
  24128. * Get the parent of the physics imposter
  24129. * @returns Physics imposter or null
  24130. */
  24131. get parent(): Nullable<PhysicsImpostor>;
  24132. /**
  24133. * Sets the parent of the physics imposter
  24134. */
  24135. set parent(value: Nullable<PhysicsImpostor>);
  24136. /**
  24137. * Set the physics body. Used mainly by the physics engine/plugin
  24138. */
  24139. set physicsBody(physicsBody: any);
  24140. /**
  24141. * Resets the update flags
  24142. */
  24143. resetUpdateFlags(): void;
  24144. /**
  24145. * Gets the object extend size
  24146. * @returns the object extend size
  24147. */
  24148. getObjectExtendSize(): Vector3;
  24149. /**
  24150. * Gets the object center
  24151. * @returns The object center
  24152. */
  24153. getObjectCenter(): Vector3;
  24154. /**
  24155. * Get a specific parameter from the options parameters
  24156. * @param paramName The object parameter name
  24157. * @returns The object parameter
  24158. */
  24159. getParam(paramName: string): any;
  24160. /**
  24161. * Sets a specific parameter in the options given to the physics plugin
  24162. * @param paramName The parameter name
  24163. * @param value The value of the parameter
  24164. */
  24165. setParam(paramName: string, value: number): void;
  24166. /**
  24167. * Specifically change the body's mass option. Won't recreate the physics body object
  24168. * @param mass The mass of the physics imposter
  24169. */
  24170. setMass(mass: number): void;
  24171. /**
  24172. * Gets the linear velocity
  24173. * @returns linear velocity or null
  24174. */
  24175. getLinearVelocity(): Nullable<Vector3>;
  24176. /**
  24177. * Sets the linear velocity
  24178. * @param velocity linear velocity or null
  24179. */
  24180. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24181. /**
  24182. * Gets the angular velocity
  24183. * @returns angular velocity or null
  24184. */
  24185. getAngularVelocity(): Nullable<Vector3>;
  24186. /**
  24187. * Sets the angular velocity
  24188. * @param velocity The velocity or null
  24189. */
  24190. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24191. /**
  24192. * Execute a function with the physics plugin native code
  24193. * Provide a function the will have two variables - the world object and the physics body object
  24194. * @param func The function to execute with the physics plugin native code
  24195. */
  24196. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24197. /**
  24198. * Register a function that will be executed before the physics world is stepping forward
  24199. * @param func The function to execute before the physics world is stepped forward
  24200. */
  24201. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24202. /**
  24203. * Unregister a function that will be executed before the physics world is stepping forward
  24204. * @param func The function to execute before the physics world is stepped forward
  24205. */
  24206. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24207. /**
  24208. * Register a function that will be executed after the physics step
  24209. * @param func The function to execute after physics step
  24210. */
  24211. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24212. /**
  24213. * Unregisters a function that will be executed after the physics step
  24214. * @param func The function to execute after physics step
  24215. */
  24216. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24217. /**
  24218. * register a function that will be executed when this impostor collides against a different body
  24219. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24220. * @param func Callback that is executed on collision
  24221. */
  24222. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24223. /**
  24224. * Unregisters the physics imposter on contact
  24225. * @param collideAgainst The physics object to collide against
  24226. * @param func Callback to execute on collision
  24227. */
  24228. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24229. private _tmpQuat;
  24230. private _tmpQuat2;
  24231. /**
  24232. * Get the parent rotation
  24233. * @returns The parent rotation
  24234. */
  24235. getParentsRotation(): Quaternion;
  24236. /**
  24237. * this function is executed by the physics engine.
  24238. */
  24239. beforeStep: () => void;
  24240. /**
  24241. * this function is executed by the physics engine
  24242. */
  24243. afterStep: () => void;
  24244. /**
  24245. * Legacy collision detection event support
  24246. */
  24247. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24248. /**
  24249. * event and body object due to cannon's event-based architecture.
  24250. */
  24251. onCollide: (e: {
  24252. body: any;
  24253. }) => void;
  24254. /**
  24255. * Apply a force
  24256. * @param force The force to apply
  24257. * @param contactPoint The contact point for the force
  24258. * @returns The physics imposter
  24259. */
  24260. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24261. /**
  24262. * Apply an impulse
  24263. * @param force The impulse force
  24264. * @param contactPoint The contact point for the impulse force
  24265. * @returns The physics imposter
  24266. */
  24267. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24268. /**
  24269. * A help function to create a joint
  24270. * @param otherImpostor A physics imposter used to create a joint
  24271. * @param jointType The type of joint
  24272. * @param jointData The data for the joint
  24273. * @returns The physics imposter
  24274. */
  24275. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24276. /**
  24277. * Add a joint to this impostor with a different impostor
  24278. * @param otherImpostor A physics imposter used to add a joint
  24279. * @param joint The joint to add
  24280. * @returns The physics imposter
  24281. */
  24282. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24283. /**
  24284. * Add an anchor to a cloth impostor
  24285. * @param otherImpostor rigid impostor to anchor to
  24286. * @param width ratio across width from 0 to 1
  24287. * @param height ratio up height from 0 to 1
  24288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24289. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24290. * @returns impostor the soft imposter
  24291. */
  24292. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24293. /**
  24294. * Add a hook to a rope impostor
  24295. * @param otherImpostor rigid impostor to anchor to
  24296. * @param length ratio across rope from 0 to 1
  24297. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24299. * @returns impostor the rope imposter
  24300. */
  24301. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24302. /**
  24303. * Will keep this body still, in a sleep mode.
  24304. * @returns the physics imposter
  24305. */
  24306. sleep(): PhysicsImpostor;
  24307. /**
  24308. * Wake the body up.
  24309. * @returns The physics imposter
  24310. */
  24311. wakeUp(): PhysicsImpostor;
  24312. /**
  24313. * Clones the physics imposter
  24314. * @param newObject The physics imposter clones to this physics-enabled object
  24315. * @returns A nullable physics imposter
  24316. */
  24317. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24318. /**
  24319. * Disposes the physics imposter
  24320. */
  24321. dispose(): void;
  24322. /**
  24323. * Sets the delta position
  24324. * @param position The delta position amount
  24325. */
  24326. setDeltaPosition(position: Vector3): void;
  24327. /**
  24328. * Sets the delta rotation
  24329. * @param rotation The delta rotation amount
  24330. */
  24331. setDeltaRotation(rotation: Quaternion): void;
  24332. /**
  24333. * Gets the box size of the physics imposter and stores the result in the input parameter
  24334. * @param result Stores the box size
  24335. * @returns The physics imposter
  24336. */
  24337. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24338. /**
  24339. * Gets the radius of the physics imposter
  24340. * @returns Radius of the physics imposter
  24341. */
  24342. getRadius(): number;
  24343. /**
  24344. * Sync a bone with this impostor
  24345. * @param bone The bone to sync to the impostor.
  24346. * @param boneMesh The mesh that the bone is influencing.
  24347. * @param jointPivot The pivot of the joint / bone in local space.
  24348. * @param distToJoint Optional distance from the impostor to the joint.
  24349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24350. */
  24351. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24352. /**
  24353. * Sync impostor to a bone
  24354. * @param bone The bone that the impostor will be synced to.
  24355. * @param boneMesh The mesh that the bone is influencing.
  24356. * @param jointPivot The pivot of the joint / bone in local space.
  24357. * @param distToJoint Optional distance from the impostor to the joint.
  24358. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24359. * @param boneAxis Optional vector3 axis the bone is aligned with
  24360. */
  24361. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24362. /**
  24363. * No-Imposter type
  24364. */
  24365. static NoImpostor: number;
  24366. /**
  24367. * Sphere-Imposter type
  24368. */
  24369. static SphereImpostor: number;
  24370. /**
  24371. * Box-Imposter type
  24372. */
  24373. static BoxImpostor: number;
  24374. /**
  24375. * Plane-Imposter type
  24376. */
  24377. static PlaneImpostor: number;
  24378. /**
  24379. * Mesh-imposter type
  24380. */
  24381. static MeshImpostor: number;
  24382. /**
  24383. * Capsule-Impostor type (Ammo.js plugin only)
  24384. */
  24385. static CapsuleImpostor: number;
  24386. /**
  24387. * Cylinder-Imposter type
  24388. */
  24389. static CylinderImpostor: number;
  24390. /**
  24391. * Particle-Imposter type
  24392. */
  24393. static ParticleImpostor: number;
  24394. /**
  24395. * Heightmap-Imposter type
  24396. */
  24397. static HeightmapImpostor: number;
  24398. /**
  24399. * ConvexHull-Impostor type (Ammo.js plugin only)
  24400. */
  24401. static ConvexHullImpostor: number;
  24402. /**
  24403. * Custom-Imposter type (Ammo.js plugin only)
  24404. */
  24405. static CustomImpostor: number;
  24406. /**
  24407. * Rope-Imposter type
  24408. */
  24409. static RopeImpostor: number;
  24410. /**
  24411. * Cloth-Imposter type
  24412. */
  24413. static ClothImpostor: number;
  24414. /**
  24415. * Softbody-Imposter type
  24416. */
  24417. static SoftbodyImpostor: number;
  24418. }
  24419. }
  24420. declare module BABYLON {
  24421. /**
  24422. * @hidden
  24423. **/
  24424. export class _CreationDataStorage {
  24425. closePath?: boolean;
  24426. closeArray?: boolean;
  24427. idx: number[];
  24428. dashSize: number;
  24429. gapSize: number;
  24430. path3D: Path3D;
  24431. pathArray: Vector3[][];
  24432. arc: number;
  24433. radius: number;
  24434. cap: number;
  24435. tessellation: number;
  24436. }
  24437. /**
  24438. * @hidden
  24439. **/
  24440. class _InstanceDataStorage {
  24441. visibleInstances: any;
  24442. batchCache: _InstancesBatch;
  24443. instancesBufferSize: number;
  24444. instancesBuffer: Nullable<Buffer>;
  24445. instancesData: Float32Array;
  24446. overridenInstanceCount: number;
  24447. isFrozen: boolean;
  24448. previousBatch: Nullable<_InstancesBatch>;
  24449. hardwareInstancedRendering: boolean;
  24450. sideOrientation: number;
  24451. manualUpdate: boolean;
  24452. }
  24453. /**
  24454. * @hidden
  24455. **/
  24456. export class _InstancesBatch {
  24457. mustReturn: boolean;
  24458. visibleInstances: Nullable<InstancedMesh[]>[];
  24459. renderSelf: boolean[];
  24460. hardwareInstancedRendering: boolean[];
  24461. }
  24462. /**
  24463. * Class used to represent renderable models
  24464. */
  24465. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24466. /**
  24467. * Mesh side orientation : usually the external or front surface
  24468. */
  24469. static readonly FRONTSIDE: number;
  24470. /**
  24471. * Mesh side orientation : usually the internal or back surface
  24472. */
  24473. static readonly BACKSIDE: number;
  24474. /**
  24475. * Mesh side orientation : both internal and external or front and back surfaces
  24476. */
  24477. static readonly DOUBLESIDE: number;
  24478. /**
  24479. * Mesh side orientation : by default, `FRONTSIDE`
  24480. */
  24481. static readonly DEFAULTSIDE: number;
  24482. /**
  24483. * Mesh cap setting : no cap
  24484. */
  24485. static readonly NO_CAP: number;
  24486. /**
  24487. * Mesh cap setting : one cap at the beginning of the mesh
  24488. */
  24489. static readonly CAP_START: number;
  24490. /**
  24491. * Mesh cap setting : one cap at the end of the mesh
  24492. */
  24493. static readonly CAP_END: number;
  24494. /**
  24495. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24496. */
  24497. static readonly CAP_ALL: number;
  24498. /**
  24499. * Mesh pattern setting : no flip or rotate
  24500. */
  24501. static readonly NO_FLIP: number;
  24502. /**
  24503. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24504. */
  24505. static readonly FLIP_TILE: number;
  24506. /**
  24507. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24508. */
  24509. static readonly ROTATE_TILE: number;
  24510. /**
  24511. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24512. */
  24513. static readonly FLIP_ROW: number;
  24514. /**
  24515. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24516. */
  24517. static readonly ROTATE_ROW: number;
  24518. /**
  24519. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24520. */
  24521. static readonly FLIP_N_ROTATE_TILE: number;
  24522. /**
  24523. * Mesh pattern setting : rotate pattern and rotate
  24524. */
  24525. static readonly FLIP_N_ROTATE_ROW: number;
  24526. /**
  24527. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24528. */
  24529. static readonly CENTER: number;
  24530. /**
  24531. * Mesh tile positioning : part tiles on left
  24532. */
  24533. static readonly LEFT: number;
  24534. /**
  24535. * Mesh tile positioning : part tiles on right
  24536. */
  24537. static readonly RIGHT: number;
  24538. /**
  24539. * Mesh tile positioning : part tiles on top
  24540. */
  24541. static readonly TOP: number;
  24542. /**
  24543. * Mesh tile positioning : part tiles on bottom
  24544. */
  24545. static readonly BOTTOM: number;
  24546. /**
  24547. * Gets the default side orientation.
  24548. * @param orientation the orientation to value to attempt to get
  24549. * @returns the default orientation
  24550. * @hidden
  24551. */
  24552. static _GetDefaultSideOrientation(orientation?: number): number;
  24553. private _internalMeshDataInfo;
  24554. /**
  24555. * An event triggered before rendering the mesh
  24556. */
  24557. get onBeforeRenderObservable(): Observable<Mesh>;
  24558. /**
  24559. * An event triggered before binding the mesh
  24560. */
  24561. get onBeforeBindObservable(): Observable<Mesh>;
  24562. /**
  24563. * An event triggered after rendering the mesh
  24564. */
  24565. get onAfterRenderObservable(): Observable<Mesh>;
  24566. /**
  24567. * An event triggered before drawing the mesh
  24568. */
  24569. get onBeforeDrawObservable(): Observable<Mesh>;
  24570. private _onBeforeDrawObserver;
  24571. /**
  24572. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24573. */
  24574. set onBeforeDraw(callback: () => void);
  24575. get hasInstances(): boolean;
  24576. /**
  24577. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24578. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24579. */
  24580. delayLoadState: number;
  24581. /**
  24582. * Gets the list of instances created from this mesh
  24583. * it is not supposed to be modified manually.
  24584. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24585. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24586. */
  24587. instances: InstancedMesh[];
  24588. /**
  24589. * Gets the file containing delay loading data for this mesh
  24590. */
  24591. delayLoadingFile: string;
  24592. /** @hidden */
  24593. _binaryInfo: any;
  24594. /**
  24595. * User defined function used to change how LOD level selection is done
  24596. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24597. */
  24598. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24599. /**
  24600. * Gets or sets the morph target manager
  24601. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24602. */
  24603. get morphTargetManager(): Nullable<MorphTargetManager>;
  24604. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24605. /** @hidden */
  24606. _creationDataStorage: Nullable<_CreationDataStorage>;
  24607. /** @hidden */
  24608. _geometry: Nullable<Geometry>;
  24609. /** @hidden */
  24610. _delayInfo: Array<string>;
  24611. /** @hidden */
  24612. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24613. /** @hidden */
  24614. _instanceDataStorage: _InstanceDataStorage;
  24615. private _effectiveMaterial;
  24616. /** @hidden */
  24617. _shouldGenerateFlatShading: boolean;
  24618. /** @hidden */
  24619. _originalBuilderSideOrientation: number;
  24620. /**
  24621. * Use this property to change the original side orientation defined at construction time
  24622. */
  24623. overrideMaterialSideOrientation: Nullable<number>;
  24624. /**
  24625. * Gets the source mesh (the one used to clone this one from)
  24626. */
  24627. get source(): Nullable<Mesh>;
  24628. /**
  24629. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24630. */
  24631. get isUnIndexed(): boolean;
  24632. set isUnIndexed(value: boolean);
  24633. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24634. get worldMatrixInstancedBuffer(): Float32Array;
  24635. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24636. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24637. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24638. /**
  24639. * @constructor
  24640. * @param name The value used by scene.getMeshByName() to do a lookup.
  24641. * @param scene The scene to add this mesh to.
  24642. * @param parent The parent of this mesh, if it has one
  24643. * @param source An optional Mesh from which geometry is shared, cloned.
  24644. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24645. * When false, achieved by calling a clone(), also passing False.
  24646. * This will make creation of children, recursive.
  24647. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24648. */
  24649. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24650. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24651. doNotInstantiate: boolean;
  24652. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24653. /**
  24654. * Gets the class name
  24655. * @returns the string "Mesh".
  24656. */
  24657. getClassName(): string;
  24658. /** @hidden */
  24659. get _isMesh(): boolean;
  24660. /**
  24661. * Returns a description of this mesh
  24662. * @param fullDetails define if full details about this mesh must be used
  24663. * @returns a descriptive string representing this mesh
  24664. */
  24665. toString(fullDetails?: boolean): string;
  24666. /** @hidden */
  24667. _unBindEffect(): void;
  24668. /**
  24669. * Gets a boolean indicating if this mesh has LOD
  24670. */
  24671. get hasLODLevels(): boolean;
  24672. /**
  24673. * Gets the list of MeshLODLevel associated with the current mesh
  24674. * @returns an array of MeshLODLevel
  24675. */
  24676. getLODLevels(): MeshLODLevel[];
  24677. private _sortLODLevels;
  24678. /**
  24679. * Add a mesh as LOD level triggered at the given distance.
  24680. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24681. * @param distance The distance from the center of the object to show this level
  24682. * @param mesh The mesh to be added as LOD level (can be null)
  24683. * @return This mesh (for chaining)
  24684. */
  24685. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24686. /**
  24687. * Returns the LOD level mesh at the passed distance or null if not found.
  24688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24689. * @param distance The distance from the center of the object to show this level
  24690. * @returns a Mesh or `null`
  24691. */
  24692. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24693. /**
  24694. * Remove a mesh from the LOD array
  24695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24696. * @param mesh defines the mesh to be removed
  24697. * @return This mesh (for chaining)
  24698. */
  24699. removeLODLevel(mesh: Mesh): Mesh;
  24700. /**
  24701. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24703. * @param camera defines the camera to use to compute distance
  24704. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24705. * @return This mesh (for chaining)
  24706. */
  24707. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24708. /**
  24709. * Gets the mesh internal Geometry object
  24710. */
  24711. get geometry(): Nullable<Geometry>;
  24712. /**
  24713. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24714. * @returns the total number of vertices
  24715. */
  24716. getTotalVertices(): number;
  24717. /**
  24718. * Returns the content of an associated vertex buffer
  24719. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24720. * - VertexBuffer.PositionKind
  24721. * - VertexBuffer.UVKind
  24722. * - VertexBuffer.UV2Kind
  24723. * - VertexBuffer.UV3Kind
  24724. * - VertexBuffer.UV4Kind
  24725. * - VertexBuffer.UV5Kind
  24726. * - VertexBuffer.UV6Kind
  24727. * - VertexBuffer.ColorKind
  24728. * - VertexBuffer.MatricesIndicesKind
  24729. * - VertexBuffer.MatricesIndicesExtraKind
  24730. * - VertexBuffer.MatricesWeightsKind
  24731. * - VertexBuffer.MatricesWeightsExtraKind
  24732. * @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
  24733. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24734. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24735. */
  24736. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24737. /**
  24738. * Returns the mesh VertexBuffer object from the requested `kind`
  24739. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24740. * - VertexBuffer.PositionKind
  24741. * - VertexBuffer.NormalKind
  24742. * - VertexBuffer.UVKind
  24743. * - VertexBuffer.UV2Kind
  24744. * - VertexBuffer.UV3Kind
  24745. * - VertexBuffer.UV4Kind
  24746. * - VertexBuffer.UV5Kind
  24747. * - VertexBuffer.UV6Kind
  24748. * - VertexBuffer.ColorKind
  24749. * - VertexBuffer.MatricesIndicesKind
  24750. * - VertexBuffer.MatricesIndicesExtraKind
  24751. * - VertexBuffer.MatricesWeightsKind
  24752. * - VertexBuffer.MatricesWeightsExtraKind
  24753. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24754. */
  24755. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24756. /**
  24757. * Tests if a specific vertex buffer is associated with this mesh
  24758. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24759. * - VertexBuffer.PositionKind
  24760. * - VertexBuffer.NormalKind
  24761. * - VertexBuffer.UVKind
  24762. * - VertexBuffer.UV2Kind
  24763. * - VertexBuffer.UV3Kind
  24764. * - VertexBuffer.UV4Kind
  24765. * - VertexBuffer.UV5Kind
  24766. * - VertexBuffer.UV6Kind
  24767. * - VertexBuffer.ColorKind
  24768. * - VertexBuffer.MatricesIndicesKind
  24769. * - VertexBuffer.MatricesIndicesExtraKind
  24770. * - VertexBuffer.MatricesWeightsKind
  24771. * - VertexBuffer.MatricesWeightsExtraKind
  24772. * @returns a boolean
  24773. */
  24774. isVerticesDataPresent(kind: string): boolean;
  24775. /**
  24776. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24778. * - VertexBuffer.PositionKind
  24779. * - VertexBuffer.UVKind
  24780. * - VertexBuffer.UV2Kind
  24781. * - VertexBuffer.UV3Kind
  24782. * - VertexBuffer.UV4Kind
  24783. * - VertexBuffer.UV5Kind
  24784. * - VertexBuffer.UV6Kind
  24785. * - VertexBuffer.ColorKind
  24786. * - VertexBuffer.MatricesIndicesKind
  24787. * - VertexBuffer.MatricesIndicesExtraKind
  24788. * - VertexBuffer.MatricesWeightsKind
  24789. * - VertexBuffer.MatricesWeightsExtraKind
  24790. * @returns a boolean
  24791. */
  24792. isVertexBufferUpdatable(kind: string): boolean;
  24793. /**
  24794. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24796. * - VertexBuffer.PositionKind
  24797. * - VertexBuffer.NormalKind
  24798. * - VertexBuffer.UVKind
  24799. * - VertexBuffer.UV2Kind
  24800. * - VertexBuffer.UV3Kind
  24801. * - VertexBuffer.UV4Kind
  24802. * - VertexBuffer.UV5Kind
  24803. * - VertexBuffer.UV6Kind
  24804. * - VertexBuffer.ColorKind
  24805. * - VertexBuffer.MatricesIndicesKind
  24806. * - VertexBuffer.MatricesIndicesExtraKind
  24807. * - VertexBuffer.MatricesWeightsKind
  24808. * - VertexBuffer.MatricesWeightsExtraKind
  24809. * @returns an array of strings
  24810. */
  24811. getVerticesDataKinds(): string[];
  24812. /**
  24813. * Returns a positive integer : the total number of indices in this mesh geometry.
  24814. * @returns the numner of indices or zero if the mesh has no geometry.
  24815. */
  24816. getTotalIndices(): number;
  24817. /**
  24818. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24819. * @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.
  24820. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24821. * @returns the indices array or an empty array if the mesh has no geometry
  24822. */
  24823. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24824. get isBlocked(): boolean;
  24825. /**
  24826. * Determine if the current mesh is ready to be rendered
  24827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24828. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24829. * @returns true if all associated assets are ready (material, textures, shaders)
  24830. */
  24831. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24832. /**
  24833. * 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.
  24834. */
  24835. get areNormalsFrozen(): boolean;
  24836. /**
  24837. * 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.
  24838. * @returns the current mesh
  24839. */
  24840. freezeNormals(): Mesh;
  24841. /**
  24842. * 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
  24843. * @returns the current mesh
  24844. */
  24845. unfreezeNormals(): Mesh;
  24846. /**
  24847. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24848. */
  24849. set overridenInstanceCount(count: number);
  24850. /** @hidden */
  24851. _preActivate(): Mesh;
  24852. /** @hidden */
  24853. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24854. /** @hidden */
  24855. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24856. /**
  24857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24858. * This means the mesh underlying bounding box and sphere are recomputed.
  24859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24860. * @returns the current mesh
  24861. */
  24862. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24863. /** @hidden */
  24864. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24865. /**
  24866. * This function will subdivide the mesh into multiple submeshes
  24867. * @param count defines the expected number of submeshes
  24868. */
  24869. subdivide(count: number): void;
  24870. /**
  24871. * Copy a FloatArray into a specific associated vertex buffer
  24872. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24873. * - VertexBuffer.PositionKind
  24874. * - VertexBuffer.UVKind
  24875. * - VertexBuffer.UV2Kind
  24876. * - VertexBuffer.UV3Kind
  24877. * - VertexBuffer.UV4Kind
  24878. * - VertexBuffer.UV5Kind
  24879. * - VertexBuffer.UV6Kind
  24880. * - VertexBuffer.ColorKind
  24881. * - VertexBuffer.MatricesIndicesKind
  24882. * - VertexBuffer.MatricesIndicesExtraKind
  24883. * - VertexBuffer.MatricesWeightsKind
  24884. * - VertexBuffer.MatricesWeightsExtraKind
  24885. * @param data defines the data source
  24886. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24887. * @param stride defines the data stride size (can be null)
  24888. * @returns the current mesh
  24889. */
  24890. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24891. /**
  24892. * Delete a vertex buffer associated with this mesh
  24893. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24894. * - VertexBuffer.PositionKind
  24895. * - VertexBuffer.UVKind
  24896. * - VertexBuffer.UV2Kind
  24897. * - VertexBuffer.UV3Kind
  24898. * - VertexBuffer.UV4Kind
  24899. * - VertexBuffer.UV5Kind
  24900. * - VertexBuffer.UV6Kind
  24901. * - VertexBuffer.ColorKind
  24902. * - VertexBuffer.MatricesIndicesKind
  24903. * - VertexBuffer.MatricesIndicesExtraKind
  24904. * - VertexBuffer.MatricesWeightsKind
  24905. * - VertexBuffer.MatricesWeightsExtraKind
  24906. */
  24907. removeVerticesData(kind: string): void;
  24908. /**
  24909. * Flags an associated vertex buffer as updatable
  24910. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24911. * - VertexBuffer.PositionKind
  24912. * - VertexBuffer.UVKind
  24913. * - VertexBuffer.UV2Kind
  24914. * - VertexBuffer.UV3Kind
  24915. * - VertexBuffer.UV4Kind
  24916. * - VertexBuffer.UV5Kind
  24917. * - VertexBuffer.UV6Kind
  24918. * - VertexBuffer.ColorKind
  24919. * - VertexBuffer.MatricesIndicesKind
  24920. * - VertexBuffer.MatricesIndicesExtraKind
  24921. * - VertexBuffer.MatricesWeightsKind
  24922. * - VertexBuffer.MatricesWeightsExtraKind
  24923. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24924. */
  24925. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24926. /**
  24927. * Sets the mesh global Vertex Buffer
  24928. * @param buffer defines the buffer to use
  24929. * @returns the current mesh
  24930. */
  24931. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24932. /**
  24933. * Update a specific associated vertex buffer
  24934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24935. * - VertexBuffer.PositionKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @param data defines the data source
  24948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24949. * @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)
  24950. * @returns the current mesh
  24951. */
  24952. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24953. /**
  24954. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24955. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24956. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24957. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24958. * @returns the current mesh
  24959. */
  24960. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24961. /**
  24962. * Creates a un-shared specific occurence of the geometry for the mesh.
  24963. * @returns the current mesh
  24964. */
  24965. makeGeometryUnique(): Mesh;
  24966. /**
  24967. * Set the index buffer of this mesh
  24968. * @param indices defines the source data
  24969. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24970. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24971. * @returns the current mesh
  24972. */
  24973. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24974. /**
  24975. * Update the current index buffer
  24976. * @param indices defines the source data
  24977. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24978. * @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)
  24979. * @returns the current mesh
  24980. */
  24981. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24982. /**
  24983. * Invert the geometry to move from a right handed system to a left handed one.
  24984. * @returns the current mesh
  24985. */
  24986. toLeftHanded(): Mesh;
  24987. /** @hidden */
  24988. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24989. /** @hidden */
  24990. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24991. /**
  24992. * Registers for this mesh a javascript function called just before the rendering process
  24993. * @param func defines the function to call before rendering this mesh
  24994. * @returns the current mesh
  24995. */
  24996. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24997. /**
  24998. * Disposes a previously registered javascript function called before the rendering
  24999. * @param func defines the function to remove
  25000. * @returns the current mesh
  25001. */
  25002. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25003. /**
  25004. * Registers for this mesh a javascript function called just after the rendering is complete
  25005. * @param func defines the function to call after rendering this mesh
  25006. * @returns the current mesh
  25007. */
  25008. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25009. /**
  25010. * Disposes a previously registered javascript function called after the rendering.
  25011. * @param func defines the function to remove
  25012. * @returns the current mesh
  25013. */
  25014. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25015. /** @hidden */
  25016. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25017. /** @hidden */
  25018. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25019. /** @hidden */
  25020. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25021. /** @hidden */
  25022. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25023. /** @hidden */
  25024. _rebuild(): void;
  25025. /** @hidden */
  25026. _freeze(): void;
  25027. /** @hidden */
  25028. _unFreeze(): void;
  25029. /**
  25030. * 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
  25031. * @param subMesh defines the subMesh to render
  25032. * @param enableAlphaMode defines if alpha mode can be changed
  25033. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25034. * @returns the current mesh
  25035. */
  25036. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25037. private _onBeforeDraw;
  25038. /**
  25039. * Renormalize the mesh and patch it up if there are no weights
  25040. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25041. * However in the case of zero weights then we set just a single influence to 1.
  25042. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25043. */
  25044. cleanMatrixWeights(): void;
  25045. private normalizeSkinFourWeights;
  25046. private normalizeSkinWeightsAndExtra;
  25047. /**
  25048. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25049. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25050. * the user know there was an issue with importing the mesh
  25051. * @returns a validation object with skinned, valid and report string
  25052. */
  25053. validateSkinning(): {
  25054. skinned: boolean;
  25055. valid: boolean;
  25056. report: string;
  25057. };
  25058. /** @hidden */
  25059. _checkDelayState(): Mesh;
  25060. private _queueLoad;
  25061. /**
  25062. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25063. * A mesh is in the frustum if its bounding box intersects the frustum
  25064. * @param frustumPlanes defines the frustum to test
  25065. * @returns true if the mesh is in the frustum planes
  25066. */
  25067. isInFrustum(frustumPlanes: Plane[]): boolean;
  25068. /**
  25069. * Sets the mesh material by the material or multiMaterial `id` property
  25070. * @param id is a string identifying the material or the multiMaterial
  25071. * @returns the current mesh
  25072. */
  25073. setMaterialByID(id: string): Mesh;
  25074. /**
  25075. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25076. * @returns an array of IAnimatable
  25077. */
  25078. getAnimatables(): IAnimatable[];
  25079. /**
  25080. * Modifies the mesh geometry according to the passed transformation matrix.
  25081. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25082. * The mesh normals are modified using the same transformation.
  25083. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25084. * @param transform defines the transform matrix to use
  25085. * @see http://doc.babylonjs.com/resources/baking_transformations
  25086. * @returns the current mesh
  25087. */
  25088. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25089. /**
  25090. * Modifies the mesh geometry according to its own current World Matrix.
  25091. * The mesh World Matrix is then reset.
  25092. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25093. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25094. * @see http://doc.babylonjs.com/resources/baking_transformations
  25095. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25096. * @returns the current mesh
  25097. */
  25098. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25099. /** @hidden */
  25100. get _positions(): Nullable<Vector3[]>;
  25101. /** @hidden */
  25102. _resetPointsArrayCache(): Mesh;
  25103. /** @hidden */
  25104. _generatePointsArray(): boolean;
  25105. /**
  25106. * Returns a new Mesh object generated from the current mesh properties.
  25107. * This method must not get confused with createInstance()
  25108. * @param name is a string, the name given to the new mesh
  25109. * @param newParent can be any Node object (default `null`)
  25110. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25111. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25112. * @returns a new mesh
  25113. */
  25114. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25115. /**
  25116. * Releases resources associated with this mesh.
  25117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25119. */
  25120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25121. /** @hidden */
  25122. _disposeInstanceSpecificData(): void;
  25123. /**
  25124. * Modifies the mesh geometry according to a displacement map.
  25125. * 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.
  25126. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25127. * @param url is a string, the URL from the image file is to be downloaded.
  25128. * @param minHeight is the lower limit of the displacement.
  25129. * @param maxHeight is the upper limit of the displacement.
  25130. * @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.
  25131. * @param uvOffset is an optional vector2 used to offset UV.
  25132. * @param uvScale is an optional vector2 used to scale UV.
  25133. * @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.
  25134. * @returns the Mesh.
  25135. */
  25136. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25137. /**
  25138. * Modifies the mesh geometry according to a displacementMap buffer.
  25139. * 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.
  25140. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25141. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25142. * @param heightMapWidth is the width of the buffer image.
  25143. * @param heightMapHeight is the height of the buffer image.
  25144. * @param minHeight is the lower limit of the displacement.
  25145. * @param maxHeight is the upper limit of the displacement.
  25146. * @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.
  25147. * @param uvOffset is an optional vector2 used to offset UV.
  25148. * @param uvScale is an optional vector2 used to scale UV.
  25149. * @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.
  25150. * @returns the Mesh.
  25151. */
  25152. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25153. /**
  25154. * Modify the mesh to get a flat shading rendering.
  25155. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25156. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25157. * @returns current mesh
  25158. */
  25159. convertToFlatShadedMesh(): Mesh;
  25160. /**
  25161. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25162. * In other words, more vertices, no more indices and a single bigger VBO.
  25163. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25164. * @returns current mesh
  25165. */
  25166. convertToUnIndexedMesh(): Mesh;
  25167. /**
  25168. * Inverses facet orientations.
  25169. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25170. * @param flipNormals will also inverts the normals
  25171. * @returns current mesh
  25172. */
  25173. flipFaces(flipNormals?: boolean): Mesh;
  25174. /**
  25175. * Increase the number of facets and hence vertices in a mesh
  25176. * Vertex normals are interpolated from existing vertex normals
  25177. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25178. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25179. */
  25180. increaseVertices(numberPerEdge: number): void;
  25181. /**
  25182. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25183. * This will undo any application of covertToFlatShadedMesh
  25184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25185. */
  25186. forceSharedVertices(): void;
  25187. /** @hidden */
  25188. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25189. /** @hidden */
  25190. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25191. /**
  25192. * Creates a new InstancedMesh object from the mesh model.
  25193. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25194. * @param name defines the name of the new instance
  25195. * @returns a new InstancedMesh
  25196. */
  25197. createInstance(name: string): InstancedMesh;
  25198. /**
  25199. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25200. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25201. * @returns the current mesh
  25202. */
  25203. synchronizeInstances(): Mesh;
  25204. /**
  25205. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25206. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25207. * This should be used together with the simplification to avoid disappearing triangles.
  25208. * @param successCallback an optional success callback to be called after the optimization finished.
  25209. * @returns the current mesh
  25210. */
  25211. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25212. /**
  25213. * Serialize current mesh
  25214. * @param serializationObject defines the object which will receive the serialization data
  25215. */
  25216. serialize(serializationObject: any): void;
  25217. /** @hidden */
  25218. _syncGeometryWithMorphTargetManager(): void;
  25219. /** @hidden */
  25220. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25221. /**
  25222. * Returns a new Mesh object parsed from the source provided.
  25223. * @param parsedMesh is the source
  25224. * @param scene defines the hosting scene
  25225. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25226. * @returns a new Mesh
  25227. */
  25228. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25229. /**
  25230. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25231. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25232. * @param name defines the name of the mesh to create
  25233. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25234. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25235. * @param closePath creates a seam between the first and the last points of each path of the path array
  25236. * @param offset is taken in account only if the `pathArray` is containing a single path
  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. * @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)
  25241. * @returns a new Mesh
  25242. */
  25243. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25244. /**
  25245. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25246. * @param name defines the name of the mesh to create
  25247. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25248. * @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
  25249. * @param scene defines the hosting scene
  25250. * @param updatable defines if the mesh must be flagged as updatable
  25251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25252. * @returns a new Mesh
  25253. */
  25254. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25255. /**
  25256. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25257. * @param name defines the name of the mesh to create
  25258. * @param size sets the size (float) of each box side (default 1)
  25259. * @param scene defines the hosting scene
  25260. * @param updatable defines if the mesh must be flagged as updatable
  25261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25262. * @returns a new Mesh
  25263. */
  25264. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25265. /**
  25266. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25267. * @param name defines the name of the mesh to create
  25268. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25269. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25270. * @param scene defines the hosting scene
  25271. * @param updatable defines if the mesh must be flagged as updatable
  25272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25273. * @returns a new Mesh
  25274. */
  25275. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25276. /**
  25277. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25278. * @param name defines the name of the mesh to create
  25279. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25280. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25281. * @param scene defines the hosting scene
  25282. * @returns a new Mesh
  25283. */
  25284. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25285. /**
  25286. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25287. * @param name defines the name of the mesh to create
  25288. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25289. * @param diameterTop set the top cap diameter (floats, default 1)
  25290. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25291. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25292. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  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 CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25299. /**
  25300. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  25303. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25304. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25305. * @param scene defines the hosting scene
  25306. * @param updatable defines if the mesh must be flagged as updatable
  25307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25308. * @returns a new Mesh
  25309. */
  25310. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25311. /**
  25312. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25313. * @param name defines the name of the mesh to create
  25314. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25315. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25316. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25317. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25318. * @param p the number of windings on X axis (positive integers, default 2)
  25319. * @param q the number of windings on Y axis (positive integers, default 3)
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @returns a new Mesh
  25324. */
  25325. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25326. /**
  25327. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25328. * @param name defines the name of the mesh to create
  25329. * @param points is an array successive Vector3
  25330. * @param scene defines the hosting scene
  25331. * @param updatable defines if the mesh must be flagged as updatable
  25332. * @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).
  25333. * @returns a new Mesh
  25334. */
  25335. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25336. /**
  25337. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25338. * @param name defines the name of the mesh to create
  25339. * @param points is an array successive Vector3
  25340. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25341. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25342. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25343. * @param scene defines the hosting scene
  25344. * @param updatable defines if the mesh must be flagged as updatable
  25345. * @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)
  25346. * @returns a new Mesh
  25347. */
  25348. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25349. /**
  25350. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25351. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25352. * 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.
  25353. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25354. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25355. * Remember you can only change the shape positions, not their number when updating a polygon.
  25356. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25357. * @param name defines the name of the mesh to create
  25358. * @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
  25359. * @param scene defines the hosting scene
  25360. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25361. * @param updatable defines if the mesh must be flagged as updatable
  25362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25363. * @param earcutInjection can be used to inject your own earcut reference
  25364. * @returns a new Mesh
  25365. */
  25366. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25367. /**
  25368. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25369. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25370. * @param name defines the name of the mesh to create
  25371. * @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
  25372. * @param depth defines the height of extrusion
  25373. * @param scene defines the hosting scene
  25374. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25375. * @param updatable defines if the mesh must be flagged as updatable
  25376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25377. * @param earcutInjection can be used to inject your own earcut reference
  25378. * @returns a new Mesh
  25379. */
  25380. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25381. /**
  25382. * Creates an extruded shape mesh.
  25383. * 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
  25384. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25385. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25386. * @param name defines the name of the mesh to create
  25387. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25388. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25389. * @param scale is the value to scale the shape
  25390. * @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
  25391. * @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
  25392. * @param scene defines the hosting scene
  25393. * @param updatable defines if the mesh must be flagged as updatable
  25394. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25395. * @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)
  25396. * @returns a new Mesh
  25397. */
  25398. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25399. /**
  25400. * Creates an custom extruded shape mesh.
  25401. * The custom extrusion is a parametric shape.
  25402. * It has no predefined shape. Its final shape will depend on the input parameters.
  25403. * Please consider using the same method from the MeshBuilder class instead
  25404. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25405. * @param name defines the name of the mesh to create
  25406. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25407. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25408. * @param scaleFunction is a custom Javascript function called on each path point
  25409. * @param rotationFunction is a custom Javascript function called on each path point
  25410. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25411. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25412. * @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
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25416. * @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)
  25417. * @returns a new Mesh
  25418. */
  25419. 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;
  25420. /**
  25421. * Creates lathe mesh.
  25422. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25423. * Please consider using the same method from the MeshBuilder class instead
  25424. * @param name defines the name of the mesh to create
  25425. * @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
  25426. * @param radius is the radius value of the lathe
  25427. * @param tessellation is the side number of the lathe.
  25428. * @param scene defines the hosting scene
  25429. * @param updatable defines if the mesh must be flagged as updatable
  25430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25431. * @returns a new Mesh
  25432. */
  25433. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25434. /**
  25435. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25436. * @param name defines the name of the mesh to create
  25437. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25438. * @param scene defines the hosting scene
  25439. * @param updatable defines if the mesh must be flagged as updatable
  25440. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25441. * @returns a new Mesh
  25442. */
  25443. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25444. /**
  25445. * Creates a 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 width set the width of the ground
  25449. * @param height set the height of the ground
  25450. * @param subdivisions sets the number of subdivisions per side
  25451. * @param scene defines the hosting scene
  25452. * @param updatable defines if the mesh must be flagged as updatable
  25453. * @returns a new Mesh
  25454. */
  25455. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25456. /**
  25457. * Creates a tiled ground mesh.
  25458. * Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param xmin set the ground minimum X coordinate
  25461. * @param zmin set the ground minimum Y coordinate
  25462. * @param xmax set the ground maximum X coordinate
  25463. * @param zmax set the ground maximum Z coordinate
  25464. * @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
  25465. * @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
  25466. * @param scene defines the hosting scene
  25467. * @param updatable defines if the mesh must be flagged as updatable
  25468. * @returns a new Mesh
  25469. */
  25470. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25471. w: number;
  25472. h: number;
  25473. }, precision: {
  25474. w: number;
  25475. h: number;
  25476. }, scene: Scene, updatable?: boolean): Mesh;
  25477. /**
  25478. * Creates a ground mesh from a height map.
  25479. * Please consider using the same method from the MeshBuilder class instead
  25480. * @see http://doc.babylonjs.com/babylon101/height_map
  25481. * @param name defines the name of the mesh to create
  25482. * @param url sets the URL of the height map image resource
  25483. * @param width set the ground width size
  25484. * @param height set the ground height size
  25485. * @param subdivisions sets the number of subdivision per side
  25486. * @param minHeight is the minimum altitude on the ground
  25487. * @param maxHeight is the maximum altitude on the ground
  25488. * @param scene defines the hosting scene
  25489. * @param updatable defines if the mesh must be flagged as updatable
  25490. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25491. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25492. * @returns a new Mesh
  25493. */
  25494. 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;
  25495. /**
  25496. * Creates a tube mesh.
  25497. * The tube is a parametric shape.
  25498. * It has no predefined shape. Its final shape will depend on the input parameters.
  25499. * Please consider using the same method from the MeshBuilder class instead
  25500. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25501. * @param name defines the name of the mesh to create
  25502. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25503. * @param radius sets the tube radius size
  25504. * @param tessellation is the number of sides on the tubular surface
  25505. * @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
  25506. * @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
  25507. * @param scene defines the hosting scene
  25508. * @param updatable defines if the mesh must be flagged as updatable
  25509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25510. * @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)
  25511. * @returns a new Mesh
  25512. */
  25513. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25514. (i: number, distance: number): number;
  25515. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25516. /**
  25517. * Creates a polyhedron mesh.
  25518. * Please consider using the same method from the MeshBuilder class instead.
  25519. * * 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
  25520. * * The parameter `size` (positive float, default 1) sets the polygon size
  25521. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25522. * * 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`
  25523. * * 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
  25524. * * 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)`)
  25525. * * 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
  25526. * * 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
  25527. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25528. * * 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
  25529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25530. * @param name defines the name of the mesh to create
  25531. * @param options defines the options used to create the mesh
  25532. * @param scene defines the hosting scene
  25533. * @returns a new Mesh
  25534. */
  25535. static CreatePolyhedron(name: string, options: {
  25536. type?: number;
  25537. size?: number;
  25538. sizeX?: number;
  25539. sizeY?: number;
  25540. sizeZ?: number;
  25541. custom?: any;
  25542. faceUV?: Vector4[];
  25543. faceColors?: Color4[];
  25544. updatable?: boolean;
  25545. sideOrientation?: number;
  25546. }, scene: Scene): Mesh;
  25547. /**
  25548. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25549. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25550. * * 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`)
  25551. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25552. * * 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
  25553. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25554. * * 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
  25555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25556. * @param name defines the name of the mesh
  25557. * @param options defines the options used to create the mesh
  25558. * @param scene defines the hosting scene
  25559. * @returns a new Mesh
  25560. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25561. */
  25562. static CreateIcoSphere(name: string, options: {
  25563. radius?: number;
  25564. flat?: boolean;
  25565. subdivisions?: number;
  25566. sideOrientation?: number;
  25567. updatable?: boolean;
  25568. }, scene: Scene): Mesh;
  25569. /**
  25570. * Creates a decal mesh.
  25571. * Please consider using the same method from the MeshBuilder class instead.
  25572. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25573. * @param name defines the name of the mesh
  25574. * @param sourceMesh defines the mesh receiving the decal
  25575. * @param position sets the position of the decal in world coordinates
  25576. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25577. * @param size sets the decal scaling
  25578. * @param angle sets the angle to rotate the decal
  25579. * @returns a new Mesh
  25580. */
  25581. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25582. /**
  25583. * Prepare internal position array for software CPU skinning
  25584. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25585. */
  25586. setPositionsForCPUSkinning(): Float32Array;
  25587. /**
  25588. * Prepare internal normal array for software CPU skinning
  25589. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25590. */
  25591. setNormalsForCPUSkinning(): Float32Array;
  25592. /**
  25593. * Updates the vertex buffer by applying transformation from the bones
  25594. * @param skeleton defines the skeleton to apply to current mesh
  25595. * @returns the current mesh
  25596. */
  25597. applySkeleton(skeleton: Skeleton): Mesh;
  25598. /**
  25599. * 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
  25600. * @param meshes defines the list of meshes to scan
  25601. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25602. */
  25603. static MinMax(meshes: AbstractMesh[]): {
  25604. min: Vector3;
  25605. max: Vector3;
  25606. };
  25607. /**
  25608. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25609. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25610. * @returns a vector3
  25611. */
  25612. static Center(meshesOrMinMaxVector: {
  25613. min: Vector3;
  25614. max: Vector3;
  25615. } | AbstractMesh[]): Vector3;
  25616. /**
  25617. * Merge the array of meshes into a single mesh for performance reasons.
  25618. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25619. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25620. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25621. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25622. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25623. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25624. * @returns a new mesh
  25625. */
  25626. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25627. /** @hidden */
  25628. addInstance(instance: InstancedMesh): void;
  25629. /** @hidden */
  25630. removeInstance(instance: InstancedMesh): void;
  25631. }
  25632. }
  25633. declare module BABYLON {
  25634. /**
  25635. * This is the base class of all the camera used in the application.
  25636. * @see http://doc.babylonjs.com/features/cameras
  25637. */
  25638. export class Camera extends Node {
  25639. /** @hidden */
  25640. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25641. /**
  25642. * This is the default projection mode used by the cameras.
  25643. * It helps recreating a feeling of perspective and better appreciate depth.
  25644. * This is the best way to simulate real life cameras.
  25645. */
  25646. static readonly PERSPECTIVE_CAMERA: number;
  25647. /**
  25648. * This helps creating camera with an orthographic mode.
  25649. * 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.
  25650. */
  25651. static readonly ORTHOGRAPHIC_CAMERA: number;
  25652. /**
  25653. * This is the default FOV mode for perspective cameras.
  25654. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25655. */
  25656. static readonly FOVMODE_VERTICAL_FIXED: number;
  25657. /**
  25658. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25659. */
  25660. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25661. /**
  25662. * This specifies ther is no need for a camera rig.
  25663. * Basically only one eye is rendered corresponding to the camera.
  25664. */
  25665. static readonly RIG_MODE_NONE: number;
  25666. /**
  25667. * Simulates a camera Rig with one blue eye and one red eye.
  25668. * This can be use with 3d blue and red glasses.
  25669. */
  25670. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25671. /**
  25672. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25673. */
  25674. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25675. /**
  25676. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25677. */
  25678. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25679. /**
  25680. * Defines that both eyes of the camera will be rendered over under each other.
  25681. */
  25682. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25683. /**
  25684. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25685. */
  25686. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25687. /**
  25688. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25689. */
  25690. static readonly RIG_MODE_VR: number;
  25691. /**
  25692. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25693. */
  25694. static readonly RIG_MODE_WEBVR: number;
  25695. /**
  25696. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25697. */
  25698. static readonly RIG_MODE_CUSTOM: number;
  25699. /**
  25700. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25701. */
  25702. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25703. /**
  25704. * Define the input manager associated with the camera.
  25705. */
  25706. inputs: CameraInputsManager<Camera>;
  25707. /** @hidden */
  25708. _position: Vector3;
  25709. /**
  25710. * Define the current local position of the camera in the scene
  25711. */
  25712. get position(): Vector3;
  25713. set position(newPosition: Vector3);
  25714. /**
  25715. * The vector the camera should consider as up.
  25716. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25717. */
  25718. upVector: Vector3;
  25719. /**
  25720. * Define the current limit on the left side for an orthographic camera
  25721. * In scene unit
  25722. */
  25723. orthoLeft: Nullable<number>;
  25724. /**
  25725. * Define the current limit on the right side for an orthographic camera
  25726. * In scene unit
  25727. */
  25728. orthoRight: Nullable<number>;
  25729. /**
  25730. * Define the current limit on the bottom side for an orthographic camera
  25731. * In scene unit
  25732. */
  25733. orthoBottom: Nullable<number>;
  25734. /**
  25735. * Define the current limit on the top side for an orthographic camera
  25736. * In scene unit
  25737. */
  25738. orthoTop: Nullable<number>;
  25739. /**
  25740. * Field Of View is set in Radians. (default is 0.8)
  25741. */
  25742. fov: number;
  25743. /**
  25744. * Define the minimum distance the camera can see from.
  25745. * This is important to note that the depth buffer are not infinite and the closer it starts
  25746. * the more your scene might encounter depth fighting issue.
  25747. */
  25748. minZ: number;
  25749. /**
  25750. * Define the maximum distance the camera can see to.
  25751. * This is important to note that the depth buffer are not infinite and the further it end
  25752. * the more your scene might encounter depth fighting issue.
  25753. */
  25754. maxZ: number;
  25755. /**
  25756. * Define the default inertia of the camera.
  25757. * This helps giving a smooth feeling to the camera movement.
  25758. */
  25759. inertia: number;
  25760. /**
  25761. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25762. */
  25763. mode: number;
  25764. /**
  25765. * Define whether the camera is intermediate.
  25766. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25767. */
  25768. isIntermediate: boolean;
  25769. /**
  25770. * Define the viewport of the camera.
  25771. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25772. */
  25773. viewport: Viewport;
  25774. /**
  25775. * Restricts the camera to viewing objects with the same layerMask.
  25776. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25777. */
  25778. layerMask: number;
  25779. /**
  25780. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25781. */
  25782. fovMode: number;
  25783. /**
  25784. * Rig mode of the camera.
  25785. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25786. * This is normally controlled byt the camera themselves as internal use.
  25787. */
  25788. cameraRigMode: number;
  25789. /**
  25790. * Defines the distance between both "eyes" in case of a RIG
  25791. */
  25792. interaxialDistance: number;
  25793. /**
  25794. * Defines if stereoscopic rendering is done side by side or over under.
  25795. */
  25796. isStereoscopicSideBySide: boolean;
  25797. /**
  25798. * 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
  25799. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25800. * else in the scene. (Eg. security camera)
  25801. *
  25802. * 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)
  25803. */
  25804. customRenderTargets: RenderTargetTexture[];
  25805. /**
  25806. * When set, the camera will render to this render target instead of the default canvas
  25807. *
  25808. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25809. */
  25810. outputRenderTarget: Nullable<RenderTargetTexture>;
  25811. /**
  25812. * Observable triggered when the camera view matrix has changed.
  25813. */
  25814. onViewMatrixChangedObservable: Observable<Camera>;
  25815. /**
  25816. * Observable triggered when the camera Projection matrix has changed.
  25817. */
  25818. onProjectionMatrixChangedObservable: Observable<Camera>;
  25819. /**
  25820. * Observable triggered when the inputs have been processed.
  25821. */
  25822. onAfterCheckInputsObservable: Observable<Camera>;
  25823. /**
  25824. * Observable triggered when reset has been called and applied to the camera.
  25825. */
  25826. onRestoreStateObservable: Observable<Camera>;
  25827. /**
  25828. * Is this camera a part of a rig system?
  25829. */
  25830. isRigCamera: boolean;
  25831. /**
  25832. * If isRigCamera set to true this will be set with the parent camera.
  25833. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25834. */
  25835. rigParent?: Camera;
  25836. /** @hidden */
  25837. _cameraRigParams: any;
  25838. /** @hidden */
  25839. _rigCameras: Camera[];
  25840. /** @hidden */
  25841. _rigPostProcess: Nullable<PostProcess>;
  25842. protected _webvrViewMatrix: Matrix;
  25843. /** @hidden */
  25844. _skipRendering: boolean;
  25845. /** @hidden */
  25846. _projectionMatrix: Matrix;
  25847. /** @hidden */
  25848. _postProcesses: Nullable<PostProcess>[];
  25849. /** @hidden */
  25850. _activeMeshes: SmartArray<AbstractMesh>;
  25851. protected _globalPosition: Vector3;
  25852. /** @hidden */
  25853. _computedViewMatrix: Matrix;
  25854. private _doNotComputeProjectionMatrix;
  25855. private _transformMatrix;
  25856. private _frustumPlanes;
  25857. private _refreshFrustumPlanes;
  25858. private _storedFov;
  25859. private _stateStored;
  25860. /**
  25861. * Instantiates a new camera object.
  25862. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25863. * @see http://doc.babylonjs.com/features/cameras
  25864. * @param name Defines the name of the camera in the scene
  25865. * @param position Defines the position of the camera
  25866. * @param scene Defines the scene the camera belongs too
  25867. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25868. */
  25869. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25870. /**
  25871. * Store current camera state (fov, position, etc..)
  25872. * @returns the camera
  25873. */
  25874. storeState(): Camera;
  25875. /**
  25876. * Restores the camera state values if it has been stored. You must call storeState() first
  25877. */
  25878. protected _restoreStateValues(): boolean;
  25879. /**
  25880. * Restored camera state. You must call storeState() first.
  25881. * @returns true if restored and false otherwise
  25882. */
  25883. restoreState(): boolean;
  25884. /**
  25885. * Gets the class name of the camera.
  25886. * @returns the class name
  25887. */
  25888. getClassName(): string;
  25889. /** @hidden */
  25890. readonly _isCamera: boolean;
  25891. /**
  25892. * Gets a string representation of the camera useful for debug purpose.
  25893. * @param fullDetails Defines that a more verboe level of logging is required
  25894. * @returns the string representation
  25895. */
  25896. toString(fullDetails?: boolean): string;
  25897. /**
  25898. * Gets the current world space position of the camera.
  25899. */
  25900. get globalPosition(): Vector3;
  25901. /**
  25902. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25903. * @returns the active meshe list
  25904. */
  25905. getActiveMeshes(): SmartArray<AbstractMesh>;
  25906. /**
  25907. * Check whether a mesh is part of the current active mesh list of the camera
  25908. * @param mesh Defines the mesh to check
  25909. * @returns true if active, false otherwise
  25910. */
  25911. isActiveMesh(mesh: Mesh): boolean;
  25912. /**
  25913. * Is this camera ready to be used/rendered
  25914. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25915. * @return true if the camera is ready
  25916. */
  25917. isReady(completeCheck?: boolean): boolean;
  25918. /** @hidden */
  25919. _initCache(): void;
  25920. /** @hidden */
  25921. _updateCache(ignoreParentClass?: boolean): void;
  25922. /** @hidden */
  25923. _isSynchronized(): boolean;
  25924. /** @hidden */
  25925. _isSynchronizedViewMatrix(): boolean;
  25926. /** @hidden */
  25927. _isSynchronizedProjectionMatrix(): boolean;
  25928. /**
  25929. * Attach the input controls to a specific dom element to get the input from.
  25930. * @param element Defines the element the controls should be listened from
  25931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25932. */
  25933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25934. /**
  25935. * Detach the current controls from the specified dom element.
  25936. * @param element Defines the element to stop listening the inputs from
  25937. */
  25938. detachControl(element: HTMLElement): void;
  25939. /**
  25940. * Update the camera state according to the different inputs gathered during the frame.
  25941. */
  25942. update(): void;
  25943. /** @hidden */
  25944. _checkInputs(): void;
  25945. /** @hidden */
  25946. get rigCameras(): Camera[];
  25947. /**
  25948. * Gets the post process used by the rig cameras
  25949. */
  25950. get rigPostProcess(): Nullable<PostProcess>;
  25951. /**
  25952. * Internal, gets the first post proces.
  25953. * @returns the first post process to be run on this camera.
  25954. */
  25955. _getFirstPostProcess(): Nullable<PostProcess>;
  25956. private _cascadePostProcessesToRigCams;
  25957. /**
  25958. * Attach a post process to the camera.
  25959. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25960. * @param postProcess The post process to attach to the camera
  25961. * @param insertAt The position of the post process in case several of them are in use in the scene
  25962. * @returns the position the post process has been inserted at
  25963. */
  25964. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25965. /**
  25966. * Detach a post process to the camera.
  25967. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25968. * @param postProcess The post process to detach from the camera
  25969. */
  25970. detachPostProcess(postProcess: PostProcess): void;
  25971. /**
  25972. * Gets the current world matrix of the camera
  25973. */
  25974. getWorldMatrix(): Matrix;
  25975. /** @hidden */
  25976. _getViewMatrix(): Matrix;
  25977. /**
  25978. * Gets the current view matrix of the camera.
  25979. * @param force forces the camera to recompute the matrix without looking at the cached state
  25980. * @returns the view matrix
  25981. */
  25982. getViewMatrix(force?: boolean): Matrix;
  25983. /**
  25984. * Freeze the projection matrix.
  25985. * It will prevent the cache check of the camera projection compute and can speed up perf
  25986. * if no parameter of the camera are meant to change
  25987. * @param projection Defines manually a projection if necessary
  25988. */
  25989. freezeProjectionMatrix(projection?: Matrix): void;
  25990. /**
  25991. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25992. */
  25993. unfreezeProjectionMatrix(): void;
  25994. /**
  25995. * Gets the current projection matrix of the camera.
  25996. * @param force forces the camera to recompute the matrix without looking at the cached state
  25997. * @returns the projection matrix
  25998. */
  25999. getProjectionMatrix(force?: boolean): Matrix;
  26000. /**
  26001. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26002. * @returns a Matrix
  26003. */
  26004. getTransformationMatrix(): Matrix;
  26005. private _updateFrustumPlanes;
  26006. /**
  26007. * Checks if a cullable object (mesh...) is in the camera frustum
  26008. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26009. * @param target The object to check
  26010. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26011. * @returns true if the object is in frustum otherwise false
  26012. */
  26013. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26014. /**
  26015. * Checks if a cullable object (mesh...) is in the camera frustum
  26016. * Unlike isInFrustum this cheks the full bounding box
  26017. * @param target The object to check
  26018. * @returns true if the object is in frustum otherwise false
  26019. */
  26020. isCompletelyInFrustum(target: ICullable): boolean;
  26021. /**
  26022. * Gets a ray in the forward direction from the camera.
  26023. * @param length Defines the length of the ray to create
  26024. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26025. * @param origin Defines the start point of the ray which defaults to the camera position
  26026. * @returns the forward ray
  26027. */
  26028. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26029. /**
  26030. * Releases resources associated with this node.
  26031. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26032. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26033. */
  26034. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26035. /** @hidden */
  26036. _isLeftCamera: boolean;
  26037. /**
  26038. * Gets the left camera of a rig setup in case of Rigged Camera
  26039. */
  26040. get isLeftCamera(): boolean;
  26041. /** @hidden */
  26042. _isRightCamera: boolean;
  26043. /**
  26044. * Gets the right camera of a rig setup in case of Rigged Camera
  26045. */
  26046. get isRightCamera(): boolean;
  26047. /**
  26048. * Gets the left camera of a rig setup in case of Rigged Camera
  26049. */
  26050. get leftCamera(): Nullable<FreeCamera>;
  26051. /**
  26052. * Gets the right camera of a rig setup in case of Rigged Camera
  26053. */
  26054. get rightCamera(): Nullable<FreeCamera>;
  26055. /**
  26056. * Gets the left camera target of a rig setup in case of Rigged Camera
  26057. * @returns the target position
  26058. */
  26059. getLeftTarget(): Nullable<Vector3>;
  26060. /**
  26061. * Gets the right camera target of a rig setup in case of Rigged Camera
  26062. * @returns the target position
  26063. */
  26064. getRightTarget(): Nullable<Vector3>;
  26065. /**
  26066. * @hidden
  26067. */
  26068. setCameraRigMode(mode: number, rigParams: any): void;
  26069. /** @hidden */
  26070. static _setStereoscopicRigMode(camera: Camera): void;
  26071. /** @hidden */
  26072. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26073. /** @hidden */
  26074. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26075. /** @hidden */
  26076. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26077. /** @hidden */
  26078. _getVRProjectionMatrix(): Matrix;
  26079. protected _updateCameraRotationMatrix(): void;
  26080. protected _updateWebVRCameraRotationMatrix(): void;
  26081. /**
  26082. * This function MUST be overwritten by the different WebVR cameras available.
  26083. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26084. * @hidden
  26085. */
  26086. _getWebVRProjectionMatrix(): Matrix;
  26087. /**
  26088. * This function MUST be overwritten by the different WebVR cameras available.
  26089. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26090. * @hidden
  26091. */
  26092. _getWebVRViewMatrix(): Matrix;
  26093. /** @hidden */
  26094. setCameraRigParameter(name: string, value: any): void;
  26095. /**
  26096. * needs to be overridden by children so sub has required properties to be copied
  26097. * @hidden
  26098. */
  26099. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26100. /**
  26101. * May need to be overridden by children
  26102. * @hidden
  26103. */
  26104. _updateRigCameras(): void;
  26105. /** @hidden */
  26106. _setupInputs(): void;
  26107. /**
  26108. * Serialiaze the camera setup to a json represention
  26109. * @returns the JSON representation
  26110. */
  26111. serialize(): any;
  26112. /**
  26113. * Clones the current camera.
  26114. * @param name The cloned camera name
  26115. * @returns the cloned camera
  26116. */
  26117. clone(name: string): Camera;
  26118. /**
  26119. * Gets the direction of the camera relative to a given local axis.
  26120. * @param localAxis Defines the reference axis to provide a relative direction.
  26121. * @return the direction
  26122. */
  26123. getDirection(localAxis: Vector3): Vector3;
  26124. /**
  26125. * Returns the current camera absolute rotation
  26126. */
  26127. get absoluteRotation(): Quaternion;
  26128. /**
  26129. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26130. * @param localAxis Defines the reference axis to provide a relative direction.
  26131. * @param result Defines the vector to store the result in
  26132. */
  26133. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26134. /**
  26135. * Gets a camera constructor for a given camera type
  26136. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26137. * @param name The name of the camera the result will be able to instantiate
  26138. * @param scene The scene the result will construct the camera in
  26139. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26140. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26141. * @returns a factory method to construc the camera
  26142. */
  26143. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26144. /**
  26145. * Compute the world matrix of the camera.
  26146. * @returns the camera world matrix
  26147. */
  26148. computeWorldMatrix(): Matrix;
  26149. /**
  26150. * Parse a JSON and creates the camera from the parsed information
  26151. * @param parsedCamera The JSON to parse
  26152. * @param scene The scene to instantiate the camera in
  26153. * @returns the newly constructed camera
  26154. */
  26155. static Parse(parsedCamera: any, scene: Scene): Camera;
  26156. }
  26157. }
  26158. declare module BABYLON {
  26159. /**
  26160. * Class containing static functions to help procedurally build meshes
  26161. */
  26162. export class DiscBuilder {
  26163. /**
  26164. * Creates a plane polygonal mesh. By default, this is a disc
  26165. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26166. * * 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
  26167. * * 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
  26168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26169. * * 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
  26170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26171. * @param name defines the name of the mesh
  26172. * @param options defines the options used to create the mesh
  26173. * @param scene defines the hosting scene
  26174. * @returns the plane polygonal mesh
  26175. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26176. */
  26177. static CreateDisc(name: string, options: {
  26178. radius?: number;
  26179. tessellation?: number;
  26180. arc?: number;
  26181. updatable?: boolean;
  26182. sideOrientation?: number;
  26183. frontUVs?: Vector4;
  26184. backUVs?: Vector4;
  26185. }, scene?: Nullable<Scene>): Mesh;
  26186. }
  26187. }
  26188. declare module BABYLON {
  26189. /**
  26190. * Options to be used when creating a FresnelParameters.
  26191. */
  26192. export type IFresnelParametersCreationOptions = {
  26193. /**
  26194. * Define the color used on edges (grazing angle)
  26195. */
  26196. leftColor?: Color3;
  26197. /**
  26198. * Define the color used on center
  26199. */
  26200. rightColor?: Color3;
  26201. /**
  26202. * Define bias applied to computed fresnel term
  26203. */
  26204. bias?: number;
  26205. /**
  26206. * Defined the power exponent applied to fresnel term
  26207. */
  26208. power?: number;
  26209. /**
  26210. * Define if the fresnel effect is enable or not.
  26211. */
  26212. isEnabled?: boolean;
  26213. };
  26214. /**
  26215. * Serialized format for FresnelParameters.
  26216. */
  26217. export type IFresnelParametersSerialized = {
  26218. /**
  26219. * Define the color used on edges (grazing angle) [as an array]
  26220. */
  26221. leftColor: number[];
  26222. /**
  26223. * Define the color used on center [as an array]
  26224. */
  26225. rightColor: number[];
  26226. /**
  26227. * Define bias applied to computed fresnel term
  26228. */
  26229. bias: number;
  26230. /**
  26231. * Defined the power exponent applied to fresnel term
  26232. */
  26233. power?: number;
  26234. /**
  26235. * Define if the fresnel effect is enable or not.
  26236. */
  26237. isEnabled: boolean;
  26238. };
  26239. /**
  26240. * This represents all the required information to add a fresnel effect on a material:
  26241. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26242. */
  26243. export class FresnelParameters {
  26244. private _isEnabled;
  26245. /**
  26246. * Define if the fresnel effect is enable or not.
  26247. */
  26248. get isEnabled(): boolean;
  26249. set isEnabled(value: boolean);
  26250. /**
  26251. * Define the color used on edges (grazing angle)
  26252. */
  26253. leftColor: Color3;
  26254. /**
  26255. * Define the color used on center
  26256. */
  26257. rightColor: Color3;
  26258. /**
  26259. * Define bias applied to computed fresnel term
  26260. */
  26261. bias: number;
  26262. /**
  26263. * Defined the power exponent applied to fresnel term
  26264. */
  26265. power: number;
  26266. /**
  26267. * Creates a new FresnelParameters object.
  26268. *
  26269. * @param options provide your own settings to optionally to override defaults
  26270. */
  26271. constructor(options?: IFresnelParametersCreationOptions);
  26272. /**
  26273. * Clones the current fresnel and its valuues
  26274. * @returns a clone fresnel configuration
  26275. */
  26276. clone(): FresnelParameters;
  26277. /**
  26278. * Determines equality between FresnelParameters objects
  26279. * @param otherFresnelParameters defines the second operand
  26280. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26281. */
  26282. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26283. /**
  26284. * Serializes the current fresnel parameters to a JSON representation.
  26285. * @return the JSON serialization
  26286. */
  26287. serialize(): IFresnelParametersSerialized;
  26288. /**
  26289. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26290. * @param parsedFresnelParameters Define the JSON representation
  26291. * @returns the parsed parameters
  26292. */
  26293. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26294. }
  26295. }
  26296. declare module BABYLON {
  26297. /**
  26298. * Base class of materials working in push mode in babylon JS
  26299. * @hidden
  26300. */
  26301. export class PushMaterial extends Material {
  26302. protected _activeEffect: Effect;
  26303. protected _normalMatrix: Matrix;
  26304. /**
  26305. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26306. * This means that the material can keep using a previous shader while a new one is being compiled.
  26307. * This is mostly used when shader parallel compilation is supported (true by default)
  26308. */
  26309. allowShaderHotSwapping: boolean;
  26310. constructor(name: string, scene: Scene);
  26311. getEffect(): Effect;
  26312. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26313. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26314. /**
  26315. * Binds the given world matrix to the active effect
  26316. *
  26317. * @param world the matrix to bind
  26318. */
  26319. bindOnlyWorldMatrix(world: Matrix): void;
  26320. /**
  26321. * Binds the given normal matrix to the active effect
  26322. *
  26323. * @param normalMatrix the matrix to bind
  26324. */
  26325. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26326. bind(world: Matrix, mesh?: Mesh): void;
  26327. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26328. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26329. }
  26330. }
  26331. declare module BABYLON {
  26332. /**
  26333. * This groups all the flags used to control the materials channel.
  26334. */
  26335. export class MaterialFlags {
  26336. private static _DiffuseTextureEnabled;
  26337. /**
  26338. * Are diffuse textures enabled in the application.
  26339. */
  26340. static get DiffuseTextureEnabled(): boolean;
  26341. static set DiffuseTextureEnabled(value: boolean);
  26342. private static _AmbientTextureEnabled;
  26343. /**
  26344. * Are ambient textures enabled in the application.
  26345. */
  26346. static get AmbientTextureEnabled(): boolean;
  26347. static set AmbientTextureEnabled(value: boolean);
  26348. private static _OpacityTextureEnabled;
  26349. /**
  26350. * Are opacity textures enabled in the application.
  26351. */
  26352. static get OpacityTextureEnabled(): boolean;
  26353. static set OpacityTextureEnabled(value: boolean);
  26354. private static _ReflectionTextureEnabled;
  26355. /**
  26356. * Are reflection textures enabled in the application.
  26357. */
  26358. static get ReflectionTextureEnabled(): boolean;
  26359. static set ReflectionTextureEnabled(value: boolean);
  26360. private static _EmissiveTextureEnabled;
  26361. /**
  26362. * Are emissive textures enabled in the application.
  26363. */
  26364. static get EmissiveTextureEnabled(): boolean;
  26365. static set EmissiveTextureEnabled(value: boolean);
  26366. private static _SpecularTextureEnabled;
  26367. /**
  26368. * Are specular textures enabled in the application.
  26369. */
  26370. static get SpecularTextureEnabled(): boolean;
  26371. static set SpecularTextureEnabled(value: boolean);
  26372. private static _BumpTextureEnabled;
  26373. /**
  26374. * Are bump textures enabled in the application.
  26375. */
  26376. static get BumpTextureEnabled(): boolean;
  26377. static set BumpTextureEnabled(value: boolean);
  26378. private static _LightmapTextureEnabled;
  26379. /**
  26380. * Are lightmap textures enabled in the application.
  26381. */
  26382. static get LightmapTextureEnabled(): boolean;
  26383. static set LightmapTextureEnabled(value: boolean);
  26384. private static _RefractionTextureEnabled;
  26385. /**
  26386. * Are refraction textures enabled in the application.
  26387. */
  26388. static get RefractionTextureEnabled(): boolean;
  26389. static set RefractionTextureEnabled(value: boolean);
  26390. private static _ColorGradingTextureEnabled;
  26391. /**
  26392. * Are color grading textures enabled in the application.
  26393. */
  26394. static get ColorGradingTextureEnabled(): boolean;
  26395. static set ColorGradingTextureEnabled(value: boolean);
  26396. private static _FresnelEnabled;
  26397. /**
  26398. * Are fresnels enabled in the application.
  26399. */
  26400. static get FresnelEnabled(): boolean;
  26401. static set FresnelEnabled(value: boolean);
  26402. private static _ClearCoatTextureEnabled;
  26403. /**
  26404. * Are clear coat textures enabled in the application.
  26405. */
  26406. static get ClearCoatTextureEnabled(): boolean;
  26407. static set ClearCoatTextureEnabled(value: boolean);
  26408. private static _ClearCoatBumpTextureEnabled;
  26409. /**
  26410. * Are clear coat bump textures enabled in the application.
  26411. */
  26412. static get ClearCoatBumpTextureEnabled(): boolean;
  26413. static set ClearCoatBumpTextureEnabled(value: boolean);
  26414. private static _ClearCoatTintTextureEnabled;
  26415. /**
  26416. * Are clear coat tint textures enabled in the application.
  26417. */
  26418. static get ClearCoatTintTextureEnabled(): boolean;
  26419. static set ClearCoatTintTextureEnabled(value: boolean);
  26420. private static _SheenTextureEnabled;
  26421. /**
  26422. * Are sheen textures enabled in the application.
  26423. */
  26424. static get SheenTextureEnabled(): boolean;
  26425. static set SheenTextureEnabled(value: boolean);
  26426. private static _AnisotropicTextureEnabled;
  26427. /**
  26428. * Are anisotropic textures enabled in the application.
  26429. */
  26430. static get AnisotropicTextureEnabled(): boolean;
  26431. static set AnisotropicTextureEnabled(value: boolean);
  26432. private static _ThicknessTextureEnabled;
  26433. /**
  26434. * Are thickness textures enabled in the application.
  26435. */
  26436. static get ThicknessTextureEnabled(): boolean;
  26437. static set ThicknessTextureEnabled(value: boolean);
  26438. }
  26439. }
  26440. declare module BABYLON {
  26441. /** @hidden */
  26442. export var defaultFragmentDeclaration: {
  26443. name: string;
  26444. shader: string;
  26445. };
  26446. }
  26447. declare module BABYLON {
  26448. /** @hidden */
  26449. export var defaultUboDeclaration: {
  26450. name: string;
  26451. shader: string;
  26452. };
  26453. }
  26454. declare module BABYLON {
  26455. /** @hidden */
  26456. export var lightFragmentDeclaration: {
  26457. name: string;
  26458. shader: string;
  26459. };
  26460. }
  26461. declare module BABYLON {
  26462. /** @hidden */
  26463. export var lightUboDeclaration: {
  26464. name: string;
  26465. shader: string;
  26466. };
  26467. }
  26468. declare module BABYLON {
  26469. /** @hidden */
  26470. export var lightsFragmentFunctions: {
  26471. name: string;
  26472. shader: string;
  26473. };
  26474. }
  26475. declare module BABYLON {
  26476. /** @hidden */
  26477. export var shadowsFragmentFunctions: {
  26478. name: string;
  26479. shader: string;
  26480. };
  26481. }
  26482. declare module BABYLON {
  26483. /** @hidden */
  26484. export var fresnelFunction: {
  26485. name: string;
  26486. shader: string;
  26487. };
  26488. }
  26489. declare module BABYLON {
  26490. /** @hidden */
  26491. export var reflectionFunction: {
  26492. name: string;
  26493. shader: string;
  26494. };
  26495. }
  26496. declare module BABYLON {
  26497. /** @hidden */
  26498. export var bumpFragmentFunctions: {
  26499. name: string;
  26500. shader: string;
  26501. };
  26502. }
  26503. declare module BABYLON {
  26504. /** @hidden */
  26505. export var logDepthDeclaration: {
  26506. name: string;
  26507. shader: string;
  26508. };
  26509. }
  26510. declare module BABYLON {
  26511. /** @hidden */
  26512. export var bumpFragment: {
  26513. name: string;
  26514. shader: string;
  26515. };
  26516. }
  26517. declare module BABYLON {
  26518. /** @hidden */
  26519. export var depthPrePass: {
  26520. name: string;
  26521. shader: string;
  26522. };
  26523. }
  26524. declare module BABYLON {
  26525. /** @hidden */
  26526. export var lightFragment: {
  26527. name: string;
  26528. shader: string;
  26529. };
  26530. }
  26531. declare module BABYLON {
  26532. /** @hidden */
  26533. export var logDepthFragment: {
  26534. name: string;
  26535. shader: string;
  26536. };
  26537. }
  26538. declare module BABYLON {
  26539. /** @hidden */
  26540. export var defaultPixelShader: {
  26541. name: string;
  26542. shader: string;
  26543. };
  26544. }
  26545. declare module BABYLON {
  26546. /** @hidden */
  26547. export var defaultVertexDeclaration: {
  26548. name: string;
  26549. shader: string;
  26550. };
  26551. }
  26552. declare module BABYLON {
  26553. /** @hidden */
  26554. export var bumpVertexDeclaration: {
  26555. name: string;
  26556. shader: string;
  26557. };
  26558. }
  26559. declare module BABYLON {
  26560. /** @hidden */
  26561. export var bumpVertex: {
  26562. name: string;
  26563. shader: string;
  26564. };
  26565. }
  26566. declare module BABYLON {
  26567. /** @hidden */
  26568. export var fogVertex: {
  26569. name: string;
  26570. shader: string;
  26571. };
  26572. }
  26573. declare module BABYLON {
  26574. /** @hidden */
  26575. export var shadowsVertex: {
  26576. name: string;
  26577. shader: string;
  26578. };
  26579. }
  26580. declare module BABYLON {
  26581. /** @hidden */
  26582. export var pointCloudVertex: {
  26583. name: string;
  26584. shader: string;
  26585. };
  26586. }
  26587. declare module BABYLON {
  26588. /** @hidden */
  26589. export var logDepthVertex: {
  26590. name: string;
  26591. shader: string;
  26592. };
  26593. }
  26594. declare module BABYLON {
  26595. /** @hidden */
  26596. export var defaultVertexShader: {
  26597. name: string;
  26598. shader: string;
  26599. };
  26600. }
  26601. declare module BABYLON {
  26602. /** @hidden */
  26603. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26604. MAINUV1: boolean;
  26605. MAINUV2: boolean;
  26606. DIFFUSE: boolean;
  26607. DIFFUSEDIRECTUV: number;
  26608. AMBIENT: boolean;
  26609. AMBIENTDIRECTUV: number;
  26610. OPACITY: boolean;
  26611. OPACITYDIRECTUV: number;
  26612. OPACITYRGB: boolean;
  26613. REFLECTION: boolean;
  26614. EMISSIVE: boolean;
  26615. EMISSIVEDIRECTUV: number;
  26616. SPECULAR: boolean;
  26617. SPECULARDIRECTUV: number;
  26618. BUMP: boolean;
  26619. BUMPDIRECTUV: number;
  26620. PARALLAX: boolean;
  26621. PARALLAXOCCLUSION: boolean;
  26622. SPECULAROVERALPHA: boolean;
  26623. CLIPPLANE: boolean;
  26624. CLIPPLANE2: boolean;
  26625. CLIPPLANE3: boolean;
  26626. CLIPPLANE4: boolean;
  26627. CLIPPLANE5: boolean;
  26628. CLIPPLANE6: boolean;
  26629. ALPHATEST: boolean;
  26630. DEPTHPREPASS: boolean;
  26631. ALPHAFROMDIFFUSE: boolean;
  26632. POINTSIZE: boolean;
  26633. FOG: boolean;
  26634. SPECULARTERM: boolean;
  26635. DIFFUSEFRESNEL: boolean;
  26636. OPACITYFRESNEL: boolean;
  26637. REFLECTIONFRESNEL: boolean;
  26638. REFRACTIONFRESNEL: boolean;
  26639. EMISSIVEFRESNEL: boolean;
  26640. FRESNEL: boolean;
  26641. NORMAL: boolean;
  26642. UV1: boolean;
  26643. UV2: boolean;
  26644. VERTEXCOLOR: boolean;
  26645. VERTEXALPHA: boolean;
  26646. NUM_BONE_INFLUENCERS: number;
  26647. BonesPerMesh: number;
  26648. BONETEXTURE: boolean;
  26649. INSTANCES: boolean;
  26650. GLOSSINESS: boolean;
  26651. ROUGHNESS: boolean;
  26652. EMISSIVEASILLUMINATION: boolean;
  26653. LINKEMISSIVEWITHDIFFUSE: boolean;
  26654. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26655. LIGHTMAP: boolean;
  26656. LIGHTMAPDIRECTUV: number;
  26657. OBJECTSPACE_NORMALMAP: boolean;
  26658. USELIGHTMAPASSHADOWMAP: boolean;
  26659. REFLECTIONMAP_3D: boolean;
  26660. REFLECTIONMAP_SPHERICAL: boolean;
  26661. REFLECTIONMAP_PLANAR: boolean;
  26662. REFLECTIONMAP_CUBIC: boolean;
  26663. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26664. REFLECTIONMAP_PROJECTION: boolean;
  26665. REFLECTIONMAP_SKYBOX: boolean;
  26666. REFLECTIONMAP_EXPLICIT: boolean;
  26667. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26668. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26669. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26670. INVERTCUBICMAP: boolean;
  26671. LOGARITHMICDEPTH: boolean;
  26672. REFRACTION: boolean;
  26673. REFRACTIONMAP_3D: boolean;
  26674. REFLECTIONOVERALPHA: boolean;
  26675. TWOSIDEDLIGHTING: boolean;
  26676. SHADOWFLOAT: boolean;
  26677. MORPHTARGETS: boolean;
  26678. MORPHTARGETS_NORMAL: boolean;
  26679. MORPHTARGETS_TANGENT: boolean;
  26680. MORPHTARGETS_UV: boolean;
  26681. NUM_MORPH_INFLUENCERS: number;
  26682. NONUNIFORMSCALING: boolean;
  26683. PREMULTIPLYALPHA: boolean;
  26684. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26685. ALPHABLEND: boolean;
  26686. IMAGEPROCESSING: boolean;
  26687. VIGNETTE: boolean;
  26688. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26689. VIGNETTEBLENDMODEOPAQUE: boolean;
  26690. TONEMAPPING: boolean;
  26691. TONEMAPPING_ACES: boolean;
  26692. CONTRAST: boolean;
  26693. COLORCURVES: boolean;
  26694. COLORGRADING: boolean;
  26695. COLORGRADING3D: boolean;
  26696. SAMPLER3DGREENDEPTH: boolean;
  26697. SAMPLER3DBGRMAP: boolean;
  26698. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26699. MULTIVIEW: boolean;
  26700. /**
  26701. * If the reflection texture on this material is in linear color space
  26702. * @hidden
  26703. */
  26704. IS_REFLECTION_LINEAR: boolean;
  26705. /**
  26706. * If the refraction texture on this material is in linear color space
  26707. * @hidden
  26708. */
  26709. IS_REFRACTION_LINEAR: boolean;
  26710. EXPOSURE: boolean;
  26711. constructor();
  26712. setReflectionMode(modeToEnable: string): void;
  26713. }
  26714. /**
  26715. * This is the default material used in Babylon. It is the best trade off between quality
  26716. * and performances.
  26717. * @see http://doc.babylonjs.com/babylon101/materials
  26718. */
  26719. export class StandardMaterial extends PushMaterial {
  26720. private _diffuseTexture;
  26721. /**
  26722. * The basic texture of the material as viewed under a light.
  26723. */
  26724. diffuseTexture: Nullable<BaseTexture>;
  26725. private _ambientTexture;
  26726. /**
  26727. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26728. */
  26729. ambientTexture: Nullable<BaseTexture>;
  26730. private _opacityTexture;
  26731. /**
  26732. * Define the transparency of the material from a texture.
  26733. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26734. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26735. */
  26736. opacityTexture: Nullable<BaseTexture>;
  26737. private _reflectionTexture;
  26738. /**
  26739. * Define the texture used to display the reflection.
  26740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26741. */
  26742. reflectionTexture: Nullable<BaseTexture>;
  26743. private _emissiveTexture;
  26744. /**
  26745. * Define texture of the material as if self lit.
  26746. * This will be mixed in the final result even in the absence of light.
  26747. */
  26748. emissiveTexture: Nullable<BaseTexture>;
  26749. private _specularTexture;
  26750. /**
  26751. * Define how the color and intensity of the highlight given by the light in the material.
  26752. */
  26753. specularTexture: Nullable<BaseTexture>;
  26754. private _bumpTexture;
  26755. /**
  26756. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26757. * 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.
  26758. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26759. */
  26760. bumpTexture: Nullable<BaseTexture>;
  26761. private _lightmapTexture;
  26762. /**
  26763. * Complex lighting can be computationally expensive to compute at runtime.
  26764. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26765. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26766. */
  26767. lightmapTexture: Nullable<BaseTexture>;
  26768. private _refractionTexture;
  26769. /**
  26770. * Define the texture used to display the refraction.
  26771. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26772. */
  26773. refractionTexture: Nullable<BaseTexture>;
  26774. /**
  26775. * The color of the material lit by the environmental background lighting.
  26776. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26777. */
  26778. ambientColor: Color3;
  26779. /**
  26780. * The basic color of the material as viewed under a light.
  26781. */
  26782. diffuseColor: Color3;
  26783. /**
  26784. * Define how the color and intensity of the highlight given by the light in the material.
  26785. */
  26786. specularColor: Color3;
  26787. /**
  26788. * Define the color of the material as if self lit.
  26789. * This will be mixed in the final result even in the absence of light.
  26790. */
  26791. emissiveColor: Color3;
  26792. /**
  26793. * Defines how sharp are the highlights in the material.
  26794. * The bigger the value the sharper giving a more glossy feeling to the result.
  26795. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26796. */
  26797. specularPower: number;
  26798. private _useAlphaFromDiffuseTexture;
  26799. /**
  26800. * Does the transparency come from the diffuse texture alpha channel.
  26801. */
  26802. useAlphaFromDiffuseTexture: boolean;
  26803. private _useEmissiveAsIllumination;
  26804. /**
  26805. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26806. */
  26807. useEmissiveAsIllumination: boolean;
  26808. private _linkEmissiveWithDiffuse;
  26809. /**
  26810. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26811. * the emissive level when the final color is close to one.
  26812. */
  26813. linkEmissiveWithDiffuse: boolean;
  26814. private _useSpecularOverAlpha;
  26815. /**
  26816. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26817. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26818. */
  26819. useSpecularOverAlpha: boolean;
  26820. private _useReflectionOverAlpha;
  26821. /**
  26822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26824. */
  26825. useReflectionOverAlpha: boolean;
  26826. private _disableLighting;
  26827. /**
  26828. * Does lights from the scene impacts this material.
  26829. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26830. */
  26831. disableLighting: boolean;
  26832. private _useObjectSpaceNormalMap;
  26833. /**
  26834. * Allows using an object space normal map (instead of tangent space).
  26835. */
  26836. useObjectSpaceNormalMap: boolean;
  26837. private _useParallax;
  26838. /**
  26839. * Is parallax enabled or not.
  26840. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26841. */
  26842. useParallax: boolean;
  26843. private _useParallaxOcclusion;
  26844. /**
  26845. * Is parallax occlusion enabled or not.
  26846. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26847. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26848. */
  26849. useParallaxOcclusion: boolean;
  26850. /**
  26851. * 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.
  26852. */
  26853. parallaxScaleBias: number;
  26854. private _roughness;
  26855. /**
  26856. * Helps to define how blurry the reflections should appears in the material.
  26857. */
  26858. roughness: number;
  26859. /**
  26860. * In case of refraction, define the value of the index of refraction.
  26861. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26862. */
  26863. indexOfRefraction: number;
  26864. /**
  26865. * Invert the refraction texture alongside the y axis.
  26866. * It can be useful with procedural textures or probe for instance.
  26867. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26868. */
  26869. invertRefractionY: boolean;
  26870. /**
  26871. * Defines the alpha limits in alpha test mode.
  26872. */
  26873. alphaCutOff: number;
  26874. private _useLightmapAsShadowmap;
  26875. /**
  26876. * In case of light mapping, define whether the map contains light or shadow informations.
  26877. */
  26878. useLightmapAsShadowmap: boolean;
  26879. private _diffuseFresnelParameters;
  26880. /**
  26881. * Define the diffuse fresnel parameters of the material.
  26882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26883. */
  26884. diffuseFresnelParameters: FresnelParameters;
  26885. private _opacityFresnelParameters;
  26886. /**
  26887. * Define the opacity fresnel parameters of the material.
  26888. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26889. */
  26890. opacityFresnelParameters: FresnelParameters;
  26891. private _reflectionFresnelParameters;
  26892. /**
  26893. * Define the reflection fresnel parameters of the material.
  26894. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26895. */
  26896. reflectionFresnelParameters: FresnelParameters;
  26897. private _refractionFresnelParameters;
  26898. /**
  26899. * Define the refraction fresnel parameters of the material.
  26900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26901. */
  26902. refractionFresnelParameters: FresnelParameters;
  26903. private _emissiveFresnelParameters;
  26904. /**
  26905. * Define the emissive fresnel parameters of the material.
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26907. */
  26908. emissiveFresnelParameters: FresnelParameters;
  26909. private _useReflectionFresnelFromSpecular;
  26910. /**
  26911. * If true automatically deducts the fresnels values from the material specularity.
  26912. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26913. */
  26914. useReflectionFresnelFromSpecular: boolean;
  26915. private _useGlossinessFromSpecularMapAlpha;
  26916. /**
  26917. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26918. */
  26919. useGlossinessFromSpecularMapAlpha: boolean;
  26920. private _maxSimultaneousLights;
  26921. /**
  26922. * Defines the maximum number of lights that can be used in the material
  26923. */
  26924. maxSimultaneousLights: number;
  26925. private _invertNormalMapX;
  26926. /**
  26927. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26928. */
  26929. invertNormalMapX: boolean;
  26930. private _invertNormalMapY;
  26931. /**
  26932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26933. */
  26934. invertNormalMapY: boolean;
  26935. private _twoSidedLighting;
  26936. /**
  26937. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26938. */
  26939. twoSidedLighting: boolean;
  26940. /**
  26941. * Default configuration related to image processing available in the standard Material.
  26942. */
  26943. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26944. /**
  26945. * Gets the image processing configuration used either in this material.
  26946. */
  26947. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26948. /**
  26949. * Sets the Default image processing configuration used either in the this material.
  26950. *
  26951. * If sets to null, the scene one is in use.
  26952. */
  26953. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26954. /**
  26955. * Keep track of the image processing observer to allow dispose and replace.
  26956. */
  26957. private _imageProcessingObserver;
  26958. /**
  26959. * Attaches a new image processing configuration to the Standard Material.
  26960. * @param configuration
  26961. */
  26962. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26963. /**
  26964. * Gets wether the color curves effect is enabled.
  26965. */
  26966. get cameraColorCurvesEnabled(): boolean;
  26967. /**
  26968. * Sets wether the color curves effect is enabled.
  26969. */
  26970. set cameraColorCurvesEnabled(value: boolean);
  26971. /**
  26972. * Gets wether the color grading effect is enabled.
  26973. */
  26974. get cameraColorGradingEnabled(): boolean;
  26975. /**
  26976. * Gets wether the color grading effect is enabled.
  26977. */
  26978. set cameraColorGradingEnabled(value: boolean);
  26979. /**
  26980. * Gets wether tonemapping is enabled or not.
  26981. */
  26982. get cameraToneMappingEnabled(): boolean;
  26983. /**
  26984. * Sets wether tonemapping is enabled or not
  26985. */
  26986. set cameraToneMappingEnabled(value: boolean);
  26987. /**
  26988. * The camera exposure used on this material.
  26989. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26990. * This corresponds to a photographic exposure.
  26991. */
  26992. get cameraExposure(): number;
  26993. /**
  26994. * The camera exposure used on this material.
  26995. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26996. * This corresponds to a photographic exposure.
  26997. */
  26998. set cameraExposure(value: number);
  26999. /**
  27000. * Gets The camera contrast used on this material.
  27001. */
  27002. get cameraContrast(): number;
  27003. /**
  27004. * Sets The camera contrast used on this material.
  27005. */
  27006. set cameraContrast(value: number);
  27007. /**
  27008. * Gets the Color Grading 2D Lookup Texture.
  27009. */
  27010. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27011. /**
  27012. * Sets the Color Grading 2D Lookup Texture.
  27013. */
  27014. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27015. /**
  27016. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27017. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27018. * 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;
  27019. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27020. */
  27021. get cameraColorCurves(): Nullable<ColorCurves>;
  27022. /**
  27023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27025. * 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;
  27026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27027. */
  27028. set cameraColorCurves(value: Nullable<ColorCurves>);
  27029. /**
  27030. * Custom callback helping to override the default shader used in the material.
  27031. */
  27032. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27033. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27034. protected _worldViewProjectionMatrix: Matrix;
  27035. protected _globalAmbientColor: Color3;
  27036. protected _useLogarithmicDepth: boolean;
  27037. protected _rebuildInParallel: boolean;
  27038. /**
  27039. * Instantiates a new standard material.
  27040. * This is the default material used in Babylon. It is the best trade off between quality
  27041. * and performances.
  27042. * @see http://doc.babylonjs.com/babylon101/materials
  27043. * @param name Define the name of the material in the scene
  27044. * @param scene Define the scene the material belong to
  27045. */
  27046. constructor(name: string, scene: Scene);
  27047. /**
  27048. * Gets a boolean indicating that current material needs to register RTT
  27049. */
  27050. get hasRenderTargetTextures(): boolean;
  27051. /**
  27052. * Gets the current class name of the material e.g. "StandardMaterial"
  27053. * Mainly use in serialization.
  27054. * @returns the class name
  27055. */
  27056. getClassName(): string;
  27057. /**
  27058. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27059. * You can try switching to logarithmic depth.
  27060. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27061. */
  27062. get useLogarithmicDepth(): boolean;
  27063. set useLogarithmicDepth(value: boolean);
  27064. /**
  27065. * Specifies if the material will require alpha blending
  27066. * @returns a boolean specifying if alpha blending is needed
  27067. */
  27068. needAlphaBlending(): boolean;
  27069. /**
  27070. * Specifies if this material should be rendered in alpha test mode
  27071. * @returns a boolean specifying if an alpha test is needed.
  27072. */
  27073. needAlphaTesting(): boolean;
  27074. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27075. /**
  27076. * Get the texture used for alpha test purpose.
  27077. * @returns the diffuse texture in case of the standard material.
  27078. */
  27079. getAlphaTestTexture(): Nullable<BaseTexture>;
  27080. /**
  27081. * Get if the submesh is ready to be used and all its information available.
  27082. * Child classes can use it to update shaders
  27083. * @param mesh defines the mesh to check
  27084. * @param subMesh defines which submesh to check
  27085. * @param useInstances specifies that instances should be used
  27086. * @returns a boolean indicating that the submesh is ready or not
  27087. */
  27088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27089. /**
  27090. * Builds the material UBO layouts.
  27091. * Used internally during the effect preparation.
  27092. */
  27093. buildUniformLayout(): void;
  27094. /**
  27095. * Unbinds the material from the mesh
  27096. */
  27097. unbind(): void;
  27098. /**
  27099. * Binds the submesh to this material by preparing the effect and shader to draw
  27100. * @param world defines the world transformation matrix
  27101. * @param mesh defines the mesh containing the submesh
  27102. * @param subMesh defines the submesh to bind the material to
  27103. */
  27104. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27105. /**
  27106. * Get the list of animatables in the material.
  27107. * @returns the list of animatables object used in the material
  27108. */
  27109. getAnimatables(): IAnimatable[];
  27110. /**
  27111. * Gets the active textures from the material
  27112. * @returns an array of textures
  27113. */
  27114. getActiveTextures(): BaseTexture[];
  27115. /**
  27116. * Specifies if the material uses a texture
  27117. * @param texture defines the texture to check against the material
  27118. * @returns a boolean specifying if the material uses the texture
  27119. */
  27120. hasTexture(texture: BaseTexture): boolean;
  27121. /**
  27122. * Disposes the material
  27123. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27124. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27125. */
  27126. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27127. /**
  27128. * Makes a duplicate of the material, and gives it a new name
  27129. * @param name defines the new name for the duplicated material
  27130. * @returns the cloned material
  27131. */
  27132. clone(name: string): StandardMaterial;
  27133. /**
  27134. * Serializes this material in a JSON representation
  27135. * @returns the serialized material object
  27136. */
  27137. serialize(): any;
  27138. /**
  27139. * Creates a standard material from parsed material data
  27140. * @param source defines the JSON representation of the material
  27141. * @param scene defines the hosting scene
  27142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27143. * @returns a new standard material
  27144. */
  27145. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27146. /**
  27147. * Are diffuse textures enabled in the application.
  27148. */
  27149. static get DiffuseTextureEnabled(): boolean;
  27150. static set DiffuseTextureEnabled(value: boolean);
  27151. /**
  27152. * Are ambient textures enabled in the application.
  27153. */
  27154. static get AmbientTextureEnabled(): boolean;
  27155. static set AmbientTextureEnabled(value: boolean);
  27156. /**
  27157. * Are opacity textures enabled in the application.
  27158. */
  27159. static get OpacityTextureEnabled(): boolean;
  27160. static set OpacityTextureEnabled(value: boolean);
  27161. /**
  27162. * Are reflection textures enabled in the application.
  27163. */
  27164. static get ReflectionTextureEnabled(): boolean;
  27165. static set ReflectionTextureEnabled(value: boolean);
  27166. /**
  27167. * Are emissive textures enabled in the application.
  27168. */
  27169. static get EmissiveTextureEnabled(): boolean;
  27170. static set EmissiveTextureEnabled(value: boolean);
  27171. /**
  27172. * Are specular textures enabled in the application.
  27173. */
  27174. static get SpecularTextureEnabled(): boolean;
  27175. static set SpecularTextureEnabled(value: boolean);
  27176. /**
  27177. * Are bump textures enabled in the application.
  27178. */
  27179. static get BumpTextureEnabled(): boolean;
  27180. static set BumpTextureEnabled(value: boolean);
  27181. /**
  27182. * Are lightmap textures enabled in the application.
  27183. */
  27184. static get LightmapTextureEnabled(): boolean;
  27185. static set LightmapTextureEnabled(value: boolean);
  27186. /**
  27187. * Are refraction textures enabled in the application.
  27188. */
  27189. static get RefractionTextureEnabled(): boolean;
  27190. static set RefractionTextureEnabled(value: boolean);
  27191. /**
  27192. * Are color grading textures enabled in the application.
  27193. */
  27194. static get ColorGradingTextureEnabled(): boolean;
  27195. static set ColorGradingTextureEnabled(value: boolean);
  27196. /**
  27197. * Are fresnels enabled in the application.
  27198. */
  27199. static get FresnelEnabled(): boolean;
  27200. static set FresnelEnabled(value: boolean);
  27201. }
  27202. }
  27203. declare module BABYLON {
  27204. /**
  27205. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27206. *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.
  27207. * The SPS is also a particle system. It provides some methods to manage the particles.
  27208. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27209. *
  27210. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27211. */
  27212. export class SolidParticleSystem implements IDisposable {
  27213. /**
  27214. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27215. * Example : var p = SPS.particles[i];
  27216. */
  27217. particles: SolidParticle[];
  27218. /**
  27219. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27220. */
  27221. nbParticles: number;
  27222. /**
  27223. * If the particles must ever face the camera (default false). Useful for planar particles.
  27224. */
  27225. billboard: boolean;
  27226. /**
  27227. * Recompute normals when adding a shape
  27228. */
  27229. recomputeNormals: boolean;
  27230. /**
  27231. * This a counter ofr your own usage. It's not set by any SPS functions.
  27232. */
  27233. counter: number;
  27234. /**
  27235. * The SPS name. This name is also given to the underlying mesh.
  27236. */
  27237. name: string;
  27238. /**
  27239. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27240. */
  27241. mesh: Mesh;
  27242. /**
  27243. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27244. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27245. */
  27246. vars: any;
  27247. /**
  27248. * This array is populated when the SPS is set as 'pickable'.
  27249. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27250. * Each element of this array is an object `{idx: int, faceId: int}`.
  27251. * `idx` is the picked particle index in the `SPS.particles` array
  27252. * `faceId` is the picked face index counted within this particle.
  27253. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27254. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27255. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27256. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27257. */
  27258. pickedParticles: {
  27259. idx: number;
  27260. faceId: number;
  27261. }[];
  27262. /**
  27263. * This array is populated when the SPS is set as 'pickable'
  27264. * Each key of this array is a submesh index.
  27265. * Each element of this array is a second array defined like this :
  27266. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27267. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27268. * `idx` is the picked particle index in the `SPS.particles` array
  27269. * `faceId` is the picked face index counted within this particle.
  27270. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27271. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27272. */
  27273. pickedBySubMesh: {
  27274. idx: number;
  27275. faceId: number;
  27276. }[][];
  27277. /**
  27278. * This array is populated when `enableDepthSort` is set to true.
  27279. * Each element of this array is an instance of the class DepthSortedParticle.
  27280. */
  27281. depthSortedParticles: DepthSortedParticle[];
  27282. /**
  27283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27284. * @hidden
  27285. */
  27286. _bSphereOnly: boolean;
  27287. /**
  27288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27289. * @hidden
  27290. */
  27291. _bSphereRadiusFactor: number;
  27292. private _scene;
  27293. private _positions;
  27294. private _indices;
  27295. private _normals;
  27296. private _colors;
  27297. private _uvs;
  27298. private _indices32;
  27299. private _positions32;
  27300. private _normals32;
  27301. private _fixedNormal32;
  27302. private _colors32;
  27303. private _uvs32;
  27304. private _index;
  27305. private _updatable;
  27306. private _pickable;
  27307. private _isVisibilityBoxLocked;
  27308. private _alwaysVisible;
  27309. private _depthSort;
  27310. private _expandable;
  27311. private _shapeCounter;
  27312. private _copy;
  27313. private _color;
  27314. private _computeParticleColor;
  27315. private _computeParticleTexture;
  27316. private _computeParticleRotation;
  27317. private _computeParticleVertex;
  27318. private _computeBoundingBox;
  27319. private _depthSortParticles;
  27320. private _camera;
  27321. private _mustUnrotateFixedNormals;
  27322. private _particlesIntersect;
  27323. private _needs32Bits;
  27324. private _isNotBuilt;
  27325. private _lastParticleId;
  27326. private _idxOfId;
  27327. private _multimaterialEnabled;
  27328. private _useModelMaterial;
  27329. private _indicesByMaterial;
  27330. private _materialIndexes;
  27331. private _depthSortFunction;
  27332. private _materialSortFunction;
  27333. private _materials;
  27334. private _multimaterial;
  27335. private _materialIndexesById;
  27336. private _defaultMaterial;
  27337. private _autoUpdateSubMeshes;
  27338. /**
  27339. * Creates a SPS (Solid Particle System) object.
  27340. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27341. * @param scene (Scene) is the scene in which the SPS is added.
  27342. * @param options defines the options of the sps e.g.
  27343. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27344. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27345. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27346. * * 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.
  27347. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27348. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27349. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27350. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27351. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27352. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27353. */
  27354. constructor(name: string, scene: Scene, options?: {
  27355. updatable?: boolean;
  27356. isPickable?: boolean;
  27357. enableDepthSort?: boolean;
  27358. particleIntersection?: boolean;
  27359. boundingSphereOnly?: boolean;
  27360. bSphereRadiusFactor?: number;
  27361. expandable?: boolean;
  27362. useModelMaterial?: boolean;
  27363. enableMultiMaterial?: boolean;
  27364. });
  27365. /**
  27366. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27367. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27368. * @returns the created mesh
  27369. */
  27370. buildMesh(): Mesh;
  27371. /**
  27372. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27373. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27374. * Thus the particles generated from `digest()` have their property `position` set yet.
  27375. * @param mesh ( Mesh ) is the mesh to be digested
  27376. * @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
  27377. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27378. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27379. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27380. * @returns the current SPS
  27381. */
  27382. digest(mesh: Mesh, options?: {
  27383. facetNb?: number;
  27384. number?: number;
  27385. delta?: number;
  27386. storage?: [];
  27387. }): SolidParticleSystem;
  27388. /**
  27389. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27390. * @hidden
  27391. */
  27392. private _unrotateFixedNormals;
  27393. /**
  27394. * Resets the temporary working copy particle
  27395. * @hidden
  27396. */
  27397. private _resetCopy;
  27398. /**
  27399. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27400. * @param p the current index in the positions array to be updated
  27401. * @param ind the current index in the indices array
  27402. * @param shape a Vector3 array, the shape geometry
  27403. * @param positions the positions array to be updated
  27404. * @param meshInd the shape indices array
  27405. * @param indices the indices array to be updated
  27406. * @param meshUV the shape uv array
  27407. * @param uvs the uv array to be updated
  27408. * @param meshCol the shape color array
  27409. * @param colors the color array to be updated
  27410. * @param meshNor the shape normals array
  27411. * @param normals the normals array to be updated
  27412. * @param idx the particle index
  27413. * @param idxInShape the particle index in its shape
  27414. * @param options the addShape() method passed options
  27415. * @model the particle model
  27416. * @hidden
  27417. */
  27418. private _meshBuilder;
  27419. /**
  27420. * Returns a shape Vector3 array from positions float array
  27421. * @param positions float array
  27422. * @returns a vector3 array
  27423. * @hidden
  27424. */
  27425. private _posToShape;
  27426. /**
  27427. * Returns a shapeUV array from a float uvs (array deep copy)
  27428. * @param uvs as a float array
  27429. * @returns a shapeUV array
  27430. * @hidden
  27431. */
  27432. private _uvsToShapeUV;
  27433. /**
  27434. * Adds a new particle object in the particles array
  27435. * @param idx particle index in particles array
  27436. * @param id particle id
  27437. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27438. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27439. * @param model particle ModelShape object
  27440. * @param shapeId model shape identifier
  27441. * @param idxInShape index of the particle in the current model
  27442. * @param bInfo model bounding info object
  27443. * @param storage target storage array, if any
  27444. * @hidden
  27445. */
  27446. private _addParticle;
  27447. /**
  27448. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27449. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27450. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27451. * @param nb (positive integer) the number of particles to be created from this model
  27452. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27453. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27454. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27455. * @returns the number of shapes in the system
  27456. */
  27457. addShape(mesh: Mesh, nb: number, options?: {
  27458. positionFunction?: any;
  27459. vertexFunction?: any;
  27460. storage?: [];
  27461. }): number;
  27462. /**
  27463. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27464. * @hidden
  27465. */
  27466. private _rebuildParticle;
  27467. /**
  27468. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27469. * @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.
  27470. * @returns the SPS.
  27471. */
  27472. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27473. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27474. * Returns an array with the removed particles.
  27475. * 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.
  27476. * The SPS can't be empty so at least one particle needs to remain in place.
  27477. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27478. * @param start index of the first particle to remove
  27479. * @param end index of the last particle to remove (included)
  27480. * @returns an array populated with the removed particles
  27481. */
  27482. removeParticles(start: number, end: number): SolidParticle[];
  27483. /**
  27484. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27485. * @param solidParticleArray an array populated with Solid Particles objects
  27486. * @returns the SPS
  27487. */
  27488. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27489. /**
  27490. * Creates a new particle and modifies the SPS mesh geometry :
  27491. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27492. * - calls _addParticle() to populate the particle array
  27493. * factorized code from addShape() and insertParticlesFromArray()
  27494. * @param idx particle index in the particles array
  27495. * @param i particle index in its shape
  27496. * @param modelShape particle ModelShape object
  27497. * @param shape shape vertex array
  27498. * @param meshInd shape indices array
  27499. * @param meshUV shape uv array
  27500. * @param meshCol shape color array
  27501. * @param meshNor shape normals array
  27502. * @param bbInfo shape bounding info
  27503. * @param storage target particle storage
  27504. * @options addShape() passed options
  27505. * @hidden
  27506. */
  27507. private _insertNewParticle;
  27508. /**
  27509. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27510. * This method calls `updateParticle()` for each particle of the SPS.
  27511. * For an animated SPS, it is usually called within the render loop.
  27512. * 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.
  27513. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27514. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27515. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27516. * @returns the SPS.
  27517. */
  27518. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27519. /**
  27520. * Disposes the SPS.
  27521. */
  27522. dispose(): void;
  27523. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27524. * idx is the particle index in the SPS
  27525. * faceId is the picked face index counted within this particle.
  27526. * Returns null if the pickInfo can't identify a picked particle.
  27527. * @param pickingInfo (PickingInfo object)
  27528. * @returns {idx: number, faceId: number} or null
  27529. */
  27530. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27531. idx: number;
  27532. faceId: number;
  27533. }>;
  27534. /**
  27535. * Returns a SolidParticle object from its identifier : particle.id
  27536. * @param id (integer) the particle Id
  27537. * @returns the searched particle or null if not found in the SPS.
  27538. */
  27539. getParticleById(id: number): Nullable<SolidParticle>;
  27540. /**
  27541. * Returns a new array populated with the particles having the passed shapeId.
  27542. * @param shapeId (integer) the shape identifier
  27543. * @returns a new solid particle array
  27544. */
  27545. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27546. /**
  27547. * Populates the passed array "ref" with the particles having the passed shapeId.
  27548. * @param shapeId the shape identifier
  27549. * @returns the SPS
  27550. * @param ref
  27551. */
  27552. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27553. /**
  27554. * Computes the required SubMeshes according the materials assigned to the particles.
  27555. * @returns the solid particle system.
  27556. * Does nothing if called before the SPS mesh is built.
  27557. */
  27558. computeSubMeshes(): SolidParticleSystem;
  27559. /**
  27560. * Sorts the solid particles by material when MultiMaterial is enabled.
  27561. * Updates the indices32 array.
  27562. * Updates the indicesByMaterial array.
  27563. * Updates the mesh indices array.
  27564. * @returns the SPS
  27565. * @hidden
  27566. */
  27567. private _sortParticlesByMaterial;
  27568. /**
  27569. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27570. * @hidden
  27571. */
  27572. private _setMaterialIndexesById;
  27573. /**
  27574. * Returns an array with unique values of Materials from the passed array
  27575. * @param array the material array to be checked and filtered
  27576. * @hidden
  27577. */
  27578. private _filterUniqueMaterialId;
  27579. /**
  27580. * Sets a new Standard Material as _defaultMaterial if not already set.
  27581. * @hidden
  27582. */
  27583. private _setDefaultMaterial;
  27584. /**
  27585. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27587. * @returns the SPS.
  27588. */
  27589. refreshVisibleSize(): SolidParticleSystem;
  27590. /**
  27591. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27592. * @param size the size (float) of the visibility box
  27593. * note : this doesn't lock the SPS mesh bounding box.
  27594. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27595. */
  27596. setVisibilityBox(size: number): void;
  27597. /**
  27598. * Gets whether the SPS as always visible or not
  27599. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27600. */
  27601. get isAlwaysVisible(): boolean;
  27602. /**
  27603. * Sets the SPS as always visible or not
  27604. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27605. */
  27606. set isAlwaysVisible(val: boolean);
  27607. /**
  27608. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27609. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27610. */
  27611. set isVisibilityBoxLocked(val: boolean);
  27612. /**
  27613. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27614. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27615. */
  27616. get isVisibilityBoxLocked(): boolean;
  27617. /**
  27618. * Tells to `setParticles()` to compute the particle rotations or not.
  27619. * Default value : true. The SPS is faster when it's set to false.
  27620. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27621. */
  27622. set computeParticleRotation(val: boolean);
  27623. /**
  27624. * Tells to `setParticles()` to compute the particle colors or not.
  27625. * Default value : true. The SPS is faster when it's set to false.
  27626. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27627. */
  27628. set computeParticleColor(val: boolean);
  27629. set computeParticleTexture(val: boolean);
  27630. /**
  27631. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27632. * Default value : false. The SPS is faster when it's set to false.
  27633. * Note : the particle custom vertex positions aren't stored values.
  27634. */
  27635. set computeParticleVertex(val: boolean);
  27636. /**
  27637. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27638. */
  27639. set computeBoundingBox(val: boolean);
  27640. /**
  27641. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27642. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27643. * Default : `true`
  27644. */
  27645. set depthSortParticles(val: boolean);
  27646. /**
  27647. * Gets if `setParticles()` computes the particle rotations or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27650. */
  27651. get computeParticleRotation(): boolean;
  27652. /**
  27653. * Gets if `setParticles()` computes the particle colors or not.
  27654. * Default value : true. The SPS is faster when it's set to false.
  27655. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27656. */
  27657. get computeParticleColor(): boolean;
  27658. /**
  27659. * Gets if `setParticles()` computes the particle textures or not.
  27660. * Default value : true. The SPS is faster when it's set to false.
  27661. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27662. */
  27663. get computeParticleTexture(): boolean;
  27664. /**
  27665. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27666. * Default value : false. The SPS is faster when it's set to false.
  27667. * Note : the particle custom vertex positions aren't stored values.
  27668. */
  27669. get computeParticleVertex(): boolean;
  27670. /**
  27671. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27672. */
  27673. get computeBoundingBox(): boolean;
  27674. /**
  27675. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27676. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27677. * Default : `true`
  27678. */
  27679. get depthSortParticles(): boolean;
  27680. /**
  27681. * Gets if the SPS is created as expandable at construction time.
  27682. * Default : `false`
  27683. */
  27684. get expandable(): boolean;
  27685. /**
  27686. * Gets if the SPS supports the Multi Materials
  27687. */
  27688. get multimaterialEnabled(): boolean;
  27689. /**
  27690. * Gets if the SPS uses the model materials for its own multimaterial.
  27691. */
  27692. get useModelMaterial(): boolean;
  27693. /**
  27694. * The SPS used material array.
  27695. */
  27696. get materials(): Material[];
  27697. /**
  27698. * Sets the SPS MultiMaterial from the passed materials.
  27699. * Note : the passed array is internally copied and not used then by reference.
  27700. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27701. */
  27702. setMultiMaterial(materials: Material[]): void;
  27703. /**
  27704. * The SPS computed multimaterial object
  27705. */
  27706. get multimaterial(): MultiMaterial;
  27707. set multimaterial(mm: MultiMaterial);
  27708. /**
  27709. * If the subMeshes must be updated on the next call to setParticles()
  27710. */
  27711. get autoUpdateSubMeshes(): boolean;
  27712. set autoUpdateSubMeshes(val: boolean);
  27713. /**
  27714. * This function does nothing. It may be overwritten to set all the particle first values.
  27715. * The SPS doesn't call this function, you may have to call it by your own.
  27716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27717. */
  27718. initParticles(): void;
  27719. /**
  27720. * This function does nothing. It may be overwritten to recycle a particle.
  27721. * The SPS doesn't call this function, you may have to call it by your own.
  27722. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27723. * @param particle The particle to recycle
  27724. * @returns the recycled particle
  27725. */
  27726. recycleParticle(particle: SolidParticle): SolidParticle;
  27727. /**
  27728. * Updates a particle : this function should be overwritten by the user.
  27729. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27730. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27731. * @example : just set a particle position or velocity and recycle conditions
  27732. * @param particle The particle to update
  27733. * @returns the updated particle
  27734. */
  27735. updateParticle(particle: SolidParticle): SolidParticle;
  27736. /**
  27737. * Updates a vertex of a particle : it can be overwritten by the user.
  27738. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27739. * @param particle the current particle
  27740. * @param vertex the current index of the current particle
  27741. * @param pt the index of the current vertex in the particle shape
  27742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27743. * @example : just set a vertex particle position
  27744. * @returns the updated vertex
  27745. */
  27746. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27747. /**
  27748. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27749. * This does nothing and may be overwritten by the user.
  27750. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27751. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27752. * @param update the boolean update value actually passed to setParticles()
  27753. */
  27754. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27755. /**
  27756. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27757. * This will be passed three parameters.
  27758. * This does nothing and may be overwritten by the user.
  27759. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27760. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27761. * @param update the boolean update value actually passed to setParticles()
  27762. */
  27763. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27764. }
  27765. }
  27766. declare module BABYLON {
  27767. /**
  27768. * Represents one particle of a solid particle system.
  27769. */
  27770. export class SolidParticle {
  27771. /**
  27772. * particle global index
  27773. */
  27774. idx: number;
  27775. /**
  27776. * particle identifier
  27777. */
  27778. id: number;
  27779. /**
  27780. * The color of the particle
  27781. */
  27782. color: Nullable<Color4>;
  27783. /**
  27784. * The world space position of the particle.
  27785. */
  27786. position: Vector3;
  27787. /**
  27788. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27789. */
  27790. rotation: Vector3;
  27791. /**
  27792. * The world space rotation quaternion of the particle.
  27793. */
  27794. rotationQuaternion: Nullable<Quaternion>;
  27795. /**
  27796. * The scaling of the particle.
  27797. */
  27798. scaling: Vector3;
  27799. /**
  27800. * The uvs of the particle.
  27801. */
  27802. uvs: Vector4;
  27803. /**
  27804. * The current speed of the particle.
  27805. */
  27806. velocity: Vector3;
  27807. /**
  27808. * The pivot point in the particle local space.
  27809. */
  27810. pivot: Vector3;
  27811. /**
  27812. * Must the particle be translated from its pivot point in its local space ?
  27813. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27814. * Default : false
  27815. */
  27816. translateFromPivot: boolean;
  27817. /**
  27818. * Is the particle active or not ?
  27819. */
  27820. alive: boolean;
  27821. /**
  27822. * Is the particle visible or not ?
  27823. */
  27824. isVisible: boolean;
  27825. /**
  27826. * Index of this particle in the global "positions" array (Internal use)
  27827. * @hidden
  27828. */
  27829. _pos: number;
  27830. /**
  27831. * @hidden Index of this particle in the global "indices" array (Internal use)
  27832. */
  27833. _ind: number;
  27834. /**
  27835. * @hidden ModelShape of this particle (Internal use)
  27836. */
  27837. _model: ModelShape;
  27838. /**
  27839. * ModelShape id of this particle
  27840. */
  27841. shapeId: number;
  27842. /**
  27843. * Index of the particle in its shape id
  27844. */
  27845. idxInShape: number;
  27846. /**
  27847. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27848. */
  27849. _modelBoundingInfo: BoundingInfo;
  27850. /**
  27851. * @hidden Particle BoundingInfo object (Internal use)
  27852. */
  27853. _boundingInfo: BoundingInfo;
  27854. /**
  27855. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27856. */
  27857. _sps: SolidParticleSystem;
  27858. /**
  27859. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27860. */
  27861. _stillInvisible: boolean;
  27862. /**
  27863. * @hidden Last computed particle rotation matrix
  27864. */
  27865. _rotationMatrix: number[];
  27866. /**
  27867. * Parent particle Id, if any.
  27868. * Default null.
  27869. */
  27870. parentId: Nullable<number>;
  27871. /**
  27872. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27873. */
  27874. materialIndex: Nullable<number>;
  27875. /**
  27876. * Custom object or properties.
  27877. */
  27878. props: Nullable<any>;
  27879. /**
  27880. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27881. * The possible values are :
  27882. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27883. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27884. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27886. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27887. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27888. * */
  27889. cullingStrategy: number;
  27890. /**
  27891. * @hidden Internal global position in the SPS.
  27892. */
  27893. _globalPosition: Vector3;
  27894. /**
  27895. * Creates a Solid Particle object.
  27896. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27897. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27898. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27899. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27900. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27901. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27902. * @param shapeId (integer) is the model shape identifier in the SPS.
  27903. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27904. * @param sps defines the sps it is associated to
  27905. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27906. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27907. */
  27908. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27909. /**
  27910. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27911. * @param target the particle target
  27912. * @returns the current particle
  27913. */
  27914. copyToRef(target: SolidParticle): SolidParticle;
  27915. /**
  27916. * Legacy support, changed scale to scaling
  27917. */
  27918. get scale(): Vector3;
  27919. /**
  27920. * Legacy support, changed scale to scaling
  27921. */
  27922. set scale(scale: Vector3);
  27923. /**
  27924. * Legacy support, changed quaternion to rotationQuaternion
  27925. */
  27926. get quaternion(): Nullable<Quaternion>;
  27927. /**
  27928. * Legacy support, changed quaternion to rotationQuaternion
  27929. */
  27930. set quaternion(q: Nullable<Quaternion>);
  27931. /**
  27932. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27933. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27934. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27935. * @returns true if it intersects
  27936. */
  27937. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27938. /**
  27939. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27940. * A particle is in the frustum if its bounding box intersects the frustum
  27941. * @param frustumPlanes defines the frustum to test
  27942. * @returns true if the particle is in the frustum planes
  27943. */
  27944. isInFrustum(frustumPlanes: Plane[]): boolean;
  27945. /**
  27946. * get the rotation matrix of the particle
  27947. * @hidden
  27948. */
  27949. getRotationMatrix(m: Matrix): void;
  27950. }
  27951. /**
  27952. * Represents the shape of the model used by one particle of a solid particle system.
  27953. * SPS internal tool, don't use it manually.
  27954. */
  27955. export class ModelShape {
  27956. /**
  27957. * The shape id
  27958. * @hidden
  27959. */
  27960. shapeID: number;
  27961. /**
  27962. * flat array of model positions (internal use)
  27963. * @hidden
  27964. */
  27965. _shape: Vector3[];
  27966. /**
  27967. * flat array of model UVs (internal use)
  27968. * @hidden
  27969. */
  27970. _shapeUV: number[];
  27971. /**
  27972. * color array of the model
  27973. * @hidden
  27974. */
  27975. _shapeColors: number[];
  27976. /**
  27977. * indices array of the model
  27978. * @hidden
  27979. */
  27980. _indices: number[];
  27981. /**
  27982. * normals array of the model
  27983. * @hidden
  27984. */
  27985. _normals: number[];
  27986. /**
  27987. * length of the shape in the model indices array (internal use)
  27988. * @hidden
  27989. */
  27990. _indicesLength: number;
  27991. /**
  27992. * Custom position function (internal use)
  27993. * @hidden
  27994. */
  27995. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27996. /**
  27997. * Custom vertex function (internal use)
  27998. * @hidden
  27999. */
  28000. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28001. /**
  28002. * Model material (internal use)
  28003. * @hidden
  28004. */
  28005. _material: Nullable<Material>;
  28006. /**
  28007. * 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.
  28008. * SPS internal tool, don't use it manually.
  28009. * @hidden
  28010. */
  28011. 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>);
  28012. }
  28013. /**
  28014. * Represents a Depth Sorted Particle in the solid particle system.
  28015. * @hidden
  28016. */
  28017. export class DepthSortedParticle {
  28018. /**
  28019. * Particle index
  28020. */
  28021. idx: number;
  28022. /**
  28023. * Index of the particle in the "indices" array
  28024. */
  28025. ind: number;
  28026. /**
  28027. * Length of the particle shape in the "indices" array
  28028. */
  28029. indicesLength: number;
  28030. /**
  28031. * Squared distance from the particle to the camera
  28032. */
  28033. sqDistance: number;
  28034. /**
  28035. * Material index when used with MultiMaterials
  28036. */
  28037. materialIndex: number;
  28038. /**
  28039. * Creates a new sorted particle
  28040. * @param materialIndex
  28041. */
  28042. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28043. }
  28044. }
  28045. declare module BABYLON {
  28046. /**
  28047. * @hidden
  28048. */
  28049. export class _MeshCollisionData {
  28050. _checkCollisions: boolean;
  28051. _collisionMask: number;
  28052. _collisionGroup: number;
  28053. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28054. _collider: Nullable<Collider>;
  28055. _oldPositionForCollisions: Vector3;
  28056. _diffPositionForCollisions: Vector3;
  28057. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28058. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28059. }
  28060. }
  28061. declare module BABYLON {
  28062. /** @hidden */
  28063. class _FacetDataStorage {
  28064. facetPositions: Vector3[];
  28065. facetNormals: Vector3[];
  28066. facetPartitioning: number[][];
  28067. facetNb: number;
  28068. partitioningSubdivisions: number;
  28069. partitioningBBoxRatio: number;
  28070. facetDataEnabled: boolean;
  28071. facetParameters: any;
  28072. bbSize: Vector3;
  28073. subDiv: {
  28074. max: number;
  28075. X: number;
  28076. Y: number;
  28077. Z: number;
  28078. };
  28079. facetDepthSort: boolean;
  28080. facetDepthSortEnabled: boolean;
  28081. depthSortedIndices: IndicesArray;
  28082. depthSortedFacets: {
  28083. ind: number;
  28084. sqDistance: number;
  28085. }[];
  28086. facetDepthSortFunction: (f1: {
  28087. ind: number;
  28088. sqDistance: number;
  28089. }, f2: {
  28090. ind: number;
  28091. sqDistance: number;
  28092. }) => number;
  28093. facetDepthSortFrom: Vector3;
  28094. facetDepthSortOrigin: Vector3;
  28095. invertedMatrix: Matrix;
  28096. }
  28097. /**
  28098. * @hidden
  28099. **/
  28100. class _InternalAbstractMeshDataInfo {
  28101. _hasVertexAlpha: boolean;
  28102. _useVertexColors: boolean;
  28103. _numBoneInfluencers: number;
  28104. _applyFog: boolean;
  28105. _receiveShadows: boolean;
  28106. _facetData: _FacetDataStorage;
  28107. _visibility: number;
  28108. _skeleton: Nullable<Skeleton>;
  28109. _layerMask: number;
  28110. _computeBonesUsingShaders: boolean;
  28111. _isActive: boolean;
  28112. _onlyForInstances: boolean;
  28113. _isActiveIntermediate: boolean;
  28114. _onlyForInstancesIntermediate: boolean;
  28115. _actAsRegularMesh: boolean;
  28116. }
  28117. /**
  28118. * Class used to store all common mesh properties
  28119. */
  28120. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28121. /** No occlusion */
  28122. static OCCLUSION_TYPE_NONE: number;
  28123. /** Occlusion set to optimisitic */
  28124. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28125. /** Occlusion set to strict */
  28126. static OCCLUSION_TYPE_STRICT: number;
  28127. /** Use an accurante occlusion algorithm */
  28128. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28129. /** Use a conservative occlusion algorithm */
  28130. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28131. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28132. * Test order :
  28133. * Is the bounding sphere outside the frustum ?
  28134. * If not, are the bounding box vertices outside the frustum ?
  28135. * It not, then the cullable object is in the frustum.
  28136. */
  28137. static readonly CULLINGSTRATEGY_STANDARD: number;
  28138. /** Culling strategy : Bounding Sphere Only.
  28139. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28140. * It's also less accurate than the standard because some not visible objects can still be selected.
  28141. * Test : is the bounding sphere outside the frustum ?
  28142. * If not, then the cullable object is in the frustum.
  28143. */
  28144. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28145. /** Culling strategy : Optimistic Inclusion.
  28146. * This in an inclusion test first, then the standard exclusion test.
  28147. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28148. * 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.
  28149. * Anyway, it's as accurate as the standard strategy.
  28150. * Test :
  28151. * Is the cullable object bounding sphere center in the frustum ?
  28152. * If not, apply the default culling strategy.
  28153. */
  28154. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28155. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28156. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28157. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28158. * 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.
  28159. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28160. * Test :
  28161. * Is the cullable object bounding sphere center in the frustum ?
  28162. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28163. */
  28164. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28165. /**
  28166. * No billboard
  28167. */
  28168. static get BILLBOARDMODE_NONE(): number;
  28169. /** Billboard on X axis */
  28170. static get BILLBOARDMODE_X(): number;
  28171. /** Billboard on Y axis */
  28172. static get BILLBOARDMODE_Y(): number;
  28173. /** Billboard on Z axis */
  28174. static get BILLBOARDMODE_Z(): number;
  28175. /** Billboard on all axes */
  28176. static get BILLBOARDMODE_ALL(): number;
  28177. /** Billboard on using position instead of orientation */
  28178. static get BILLBOARDMODE_USE_POSITION(): number;
  28179. /** @hidden */
  28180. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28181. /**
  28182. * The culling strategy to use to check whether the mesh must be rendered or not.
  28183. * This value can be changed at any time and will be used on the next render mesh selection.
  28184. * The possible values are :
  28185. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28186. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28187. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28188. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28189. * Please read each static variable documentation to get details about the culling process.
  28190. * */
  28191. cullingStrategy: number;
  28192. /**
  28193. * Gets the number of facets in the mesh
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28195. */
  28196. get facetNb(): number;
  28197. /**
  28198. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28200. */
  28201. get partitioningSubdivisions(): number;
  28202. set partitioningSubdivisions(nb: number);
  28203. /**
  28204. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28205. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28207. */
  28208. get partitioningBBoxRatio(): number;
  28209. set partitioningBBoxRatio(ratio: number);
  28210. /**
  28211. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28212. * Works only for updatable meshes.
  28213. * Doesn't work with multi-materials
  28214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28215. */
  28216. get mustDepthSortFacets(): boolean;
  28217. set mustDepthSortFacets(sort: boolean);
  28218. /**
  28219. * The location (Vector3) where the facet depth sort must be computed from.
  28220. * By default, the active camera position.
  28221. * Used only when facet depth sort is enabled
  28222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28223. */
  28224. get facetDepthSortFrom(): Vector3;
  28225. set facetDepthSortFrom(location: Vector3);
  28226. /**
  28227. * gets a boolean indicating if facetData is enabled
  28228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28229. */
  28230. get isFacetDataEnabled(): boolean;
  28231. /** @hidden */
  28232. _updateNonUniformScalingState(value: boolean): boolean;
  28233. /**
  28234. * An event triggered when this mesh collides with another one
  28235. */
  28236. onCollideObservable: Observable<AbstractMesh>;
  28237. /** Set a function to call when this mesh collides with another one */
  28238. set onCollide(callback: () => void);
  28239. /**
  28240. * An event triggered when the collision's position changes
  28241. */
  28242. onCollisionPositionChangeObservable: Observable<Vector3>;
  28243. /** Set a function to call when the collision's position changes */
  28244. set onCollisionPositionChange(callback: () => void);
  28245. /**
  28246. * An event triggered when material is changed
  28247. */
  28248. onMaterialChangedObservable: Observable<AbstractMesh>;
  28249. /**
  28250. * Gets or sets the orientation for POV movement & rotation
  28251. */
  28252. definedFacingForward: boolean;
  28253. /** @hidden */
  28254. _occlusionQuery: Nullable<WebGLQuery>;
  28255. /** @hidden */
  28256. _renderingGroup: Nullable<RenderingGroup>;
  28257. /**
  28258. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28259. */
  28260. get visibility(): number;
  28261. /**
  28262. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28263. */
  28264. set visibility(value: number);
  28265. /** Gets or sets the alpha index used to sort transparent meshes
  28266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28267. */
  28268. alphaIndex: number;
  28269. /**
  28270. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28271. */
  28272. isVisible: boolean;
  28273. /**
  28274. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28275. */
  28276. isPickable: boolean;
  28277. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28278. showSubMeshesBoundingBox: boolean;
  28279. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28280. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28281. */
  28282. isBlocker: boolean;
  28283. /**
  28284. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28285. */
  28286. enablePointerMoveEvents: boolean;
  28287. /**
  28288. * Specifies the rendering group id for this mesh (0 by default)
  28289. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28290. */
  28291. renderingGroupId: number;
  28292. private _material;
  28293. /** Gets or sets current material */
  28294. get material(): Nullable<Material>;
  28295. set material(value: Nullable<Material>);
  28296. /**
  28297. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28298. * @see http://doc.babylonjs.com/babylon101/shadows
  28299. */
  28300. get receiveShadows(): boolean;
  28301. set receiveShadows(value: boolean);
  28302. /** Defines color to use when rendering outline */
  28303. outlineColor: Color3;
  28304. /** Define width to use when rendering outline */
  28305. outlineWidth: number;
  28306. /** Defines color to use when rendering overlay */
  28307. overlayColor: Color3;
  28308. /** Defines alpha to use when rendering overlay */
  28309. overlayAlpha: number;
  28310. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28311. get hasVertexAlpha(): boolean;
  28312. set hasVertexAlpha(value: boolean);
  28313. /** 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) */
  28314. get useVertexColors(): boolean;
  28315. set useVertexColors(value: boolean);
  28316. /**
  28317. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28318. */
  28319. get computeBonesUsingShaders(): boolean;
  28320. set computeBonesUsingShaders(value: boolean);
  28321. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28322. get numBoneInfluencers(): number;
  28323. set numBoneInfluencers(value: number);
  28324. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28325. get applyFog(): boolean;
  28326. set applyFog(value: boolean);
  28327. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28328. useOctreeForRenderingSelection: boolean;
  28329. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28330. useOctreeForPicking: boolean;
  28331. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28332. useOctreeForCollisions: boolean;
  28333. /**
  28334. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28335. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28336. */
  28337. get layerMask(): number;
  28338. set layerMask(value: number);
  28339. /**
  28340. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28341. */
  28342. alwaysSelectAsActiveMesh: boolean;
  28343. /**
  28344. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28345. */
  28346. doNotSyncBoundingInfo: boolean;
  28347. /**
  28348. * Gets or sets the current action manager
  28349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28350. */
  28351. actionManager: Nullable<AbstractActionManager>;
  28352. private _meshCollisionData;
  28353. /**
  28354. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28356. */
  28357. ellipsoid: Vector3;
  28358. /**
  28359. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28361. */
  28362. ellipsoidOffset: Vector3;
  28363. /**
  28364. * Gets or sets a collision mask used to mask collisions (default is -1).
  28365. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28366. */
  28367. get collisionMask(): number;
  28368. set collisionMask(mask: number);
  28369. /**
  28370. * Gets or sets the current collision group mask (-1 by default).
  28371. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28372. */
  28373. get collisionGroup(): number;
  28374. set collisionGroup(mask: number);
  28375. /**
  28376. * Gets or sets current surrounding meshes (null by default).
  28377. *
  28378. * By default collision detection is tested against every mesh in the scene.
  28379. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28380. * meshes will be tested for the collision.
  28381. *
  28382. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28383. */
  28384. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28385. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28386. /**
  28387. * Defines edge width used when edgesRenderer is enabled
  28388. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28389. */
  28390. edgesWidth: number;
  28391. /**
  28392. * Defines edge color used when edgesRenderer is enabled
  28393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28394. */
  28395. edgesColor: Color4;
  28396. /** @hidden */
  28397. _edgesRenderer: Nullable<IEdgesRenderer>;
  28398. /** @hidden */
  28399. _masterMesh: Nullable<AbstractMesh>;
  28400. /** @hidden */
  28401. _boundingInfo: Nullable<BoundingInfo>;
  28402. /** @hidden */
  28403. _renderId: number;
  28404. /**
  28405. * Gets or sets the list of subMeshes
  28406. * @see http://doc.babylonjs.com/how_to/multi_materials
  28407. */
  28408. subMeshes: SubMesh[];
  28409. /** @hidden */
  28410. _intersectionsInProgress: AbstractMesh[];
  28411. /** @hidden */
  28412. _unIndexed: boolean;
  28413. /** @hidden */
  28414. _lightSources: Light[];
  28415. /** Gets the list of lights affecting that mesh */
  28416. get lightSources(): Light[];
  28417. /** @hidden */
  28418. get _positions(): Nullable<Vector3[]>;
  28419. /** @hidden */
  28420. _waitingData: {
  28421. lods: Nullable<any>;
  28422. actions: Nullable<any>;
  28423. freezeWorldMatrix: Nullable<boolean>;
  28424. };
  28425. /** @hidden */
  28426. _bonesTransformMatrices: Nullable<Float32Array>;
  28427. /** @hidden */
  28428. _transformMatrixTexture: Nullable<RawTexture>;
  28429. /**
  28430. * Gets or sets a skeleton to apply skining transformations
  28431. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28432. */
  28433. set skeleton(value: Nullable<Skeleton>);
  28434. get skeleton(): Nullable<Skeleton>;
  28435. /**
  28436. * An event triggered when the mesh is rebuilt.
  28437. */
  28438. onRebuildObservable: Observable<AbstractMesh>;
  28439. /**
  28440. * Creates a new AbstractMesh
  28441. * @param name defines the name of the mesh
  28442. * @param scene defines the hosting scene
  28443. */
  28444. constructor(name: string, scene?: Nullable<Scene>);
  28445. /**
  28446. * Returns the string "AbstractMesh"
  28447. * @returns "AbstractMesh"
  28448. */
  28449. getClassName(): string;
  28450. /**
  28451. * Gets a string representation of the current mesh
  28452. * @param fullDetails defines a boolean indicating if full details must be included
  28453. * @returns a string representation of the current mesh
  28454. */
  28455. toString(fullDetails?: boolean): string;
  28456. /**
  28457. * @hidden
  28458. */
  28459. protected _getEffectiveParent(): Nullable<Node>;
  28460. /** @hidden */
  28461. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28462. /** @hidden */
  28463. _rebuild(): void;
  28464. /** @hidden */
  28465. _resyncLightSources(): void;
  28466. /** @hidden */
  28467. _resyncLightSource(light: Light): void;
  28468. /** @hidden */
  28469. _unBindEffect(): void;
  28470. /** @hidden */
  28471. _removeLightSource(light: Light, dispose: boolean): void;
  28472. private _markSubMeshesAsDirty;
  28473. /** @hidden */
  28474. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28475. /** @hidden */
  28476. _markSubMeshesAsAttributesDirty(): void;
  28477. /** @hidden */
  28478. _markSubMeshesAsMiscDirty(): void;
  28479. /**
  28480. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28481. */
  28482. get scaling(): Vector3;
  28483. set scaling(newScaling: Vector3);
  28484. /**
  28485. * Returns true if the mesh is blocked. Implemented by child classes
  28486. */
  28487. get isBlocked(): boolean;
  28488. /**
  28489. * Returns the mesh itself by default. Implemented by child classes
  28490. * @param camera defines the camera to use to pick the right LOD level
  28491. * @returns the currentAbstractMesh
  28492. */
  28493. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28494. /**
  28495. * Returns 0 by default. Implemented by child classes
  28496. * @returns an integer
  28497. */
  28498. getTotalVertices(): number;
  28499. /**
  28500. * Returns a positive integer : the total number of indices in this mesh geometry.
  28501. * @returns the numner of indices or zero if the mesh has no geometry.
  28502. */
  28503. getTotalIndices(): number;
  28504. /**
  28505. * Returns null by default. Implemented by child classes
  28506. * @returns null
  28507. */
  28508. getIndices(): Nullable<IndicesArray>;
  28509. /**
  28510. * Returns the array of the requested vertex data kind. Implemented by child classes
  28511. * @param kind defines the vertex data kind to use
  28512. * @returns null
  28513. */
  28514. getVerticesData(kind: string): Nullable<FloatArray>;
  28515. /**
  28516. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28517. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28518. * Note that a new underlying VertexBuffer object is created each call.
  28519. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28520. * @param kind defines vertex data kind:
  28521. * * VertexBuffer.PositionKind
  28522. * * VertexBuffer.UVKind
  28523. * * VertexBuffer.UV2Kind
  28524. * * VertexBuffer.UV3Kind
  28525. * * VertexBuffer.UV4Kind
  28526. * * VertexBuffer.UV5Kind
  28527. * * VertexBuffer.UV6Kind
  28528. * * VertexBuffer.ColorKind
  28529. * * VertexBuffer.MatricesIndicesKind
  28530. * * VertexBuffer.MatricesIndicesExtraKind
  28531. * * VertexBuffer.MatricesWeightsKind
  28532. * * VertexBuffer.MatricesWeightsExtraKind
  28533. * @param data defines the data source
  28534. * @param updatable defines if the data must be flagged as updatable (or static)
  28535. * @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
  28536. * @returns the current mesh
  28537. */
  28538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28539. /**
  28540. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28541. * If the mesh has no geometry, it is simply returned as it is.
  28542. * @param kind defines vertex data kind:
  28543. * * VertexBuffer.PositionKind
  28544. * * VertexBuffer.UVKind
  28545. * * VertexBuffer.UV2Kind
  28546. * * VertexBuffer.UV3Kind
  28547. * * VertexBuffer.UV4Kind
  28548. * * VertexBuffer.UV5Kind
  28549. * * VertexBuffer.UV6Kind
  28550. * * VertexBuffer.ColorKind
  28551. * * VertexBuffer.MatricesIndicesKind
  28552. * * VertexBuffer.MatricesIndicesExtraKind
  28553. * * VertexBuffer.MatricesWeightsKind
  28554. * * VertexBuffer.MatricesWeightsExtraKind
  28555. * @param data defines the data source
  28556. * @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
  28557. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28558. * @returns the current mesh
  28559. */
  28560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28561. /**
  28562. * Sets the mesh indices,
  28563. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28564. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28565. * @param totalVertices Defines the total number of vertices
  28566. * @returns the current mesh
  28567. */
  28568. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28569. /**
  28570. * Gets a boolean indicating if specific vertex data is present
  28571. * @param kind defines the vertex data kind to use
  28572. * @returns true is data kind is present
  28573. */
  28574. isVerticesDataPresent(kind: string): boolean;
  28575. /**
  28576. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28577. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28578. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28579. * @returns a BoundingInfo
  28580. */
  28581. getBoundingInfo(): BoundingInfo;
  28582. /**
  28583. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28584. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28585. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28586. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28587. * @returns the current mesh
  28588. */
  28589. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28590. /**
  28591. * Overwrite the current bounding info
  28592. * @param boundingInfo defines the new bounding info
  28593. * @returns the current mesh
  28594. */
  28595. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28596. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28597. get useBones(): boolean;
  28598. /** @hidden */
  28599. _preActivate(): void;
  28600. /** @hidden */
  28601. _preActivateForIntermediateRendering(renderId: number): void;
  28602. /** @hidden */
  28603. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28604. /** @hidden */
  28605. _postActivate(): void;
  28606. /** @hidden */
  28607. _freeze(): void;
  28608. /** @hidden */
  28609. _unFreeze(): void;
  28610. /**
  28611. * Gets the current world matrix
  28612. * @returns a Matrix
  28613. */
  28614. getWorldMatrix(): Matrix;
  28615. /** @hidden */
  28616. _getWorldMatrixDeterminant(): number;
  28617. /**
  28618. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28619. */
  28620. get isAnInstance(): boolean;
  28621. /**
  28622. * Gets a boolean indicating if this mesh has instances
  28623. */
  28624. get hasInstances(): boolean;
  28625. /**
  28626. * Perform relative position change from the point of view of behind the front of the mesh.
  28627. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28628. * Supports definition of mesh facing forward or backward
  28629. * @param amountRight defines the distance on the right axis
  28630. * @param amountUp defines the distance on the up axis
  28631. * @param amountForward defines the distance on the forward axis
  28632. * @returns the current mesh
  28633. */
  28634. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28635. /**
  28636. * Calculate relative position change from the point of view of behind the front of the mesh.
  28637. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28638. * Supports definition of mesh facing forward or backward
  28639. * @param amountRight defines the distance on the right axis
  28640. * @param amountUp defines the distance on the up axis
  28641. * @param amountForward defines the distance on the forward axis
  28642. * @returns the new displacement vector
  28643. */
  28644. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28645. /**
  28646. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28647. * Supports definition of mesh facing forward or backward
  28648. * @param flipBack defines the flip
  28649. * @param twirlClockwise defines the twirl
  28650. * @param tiltRight defines the tilt
  28651. * @returns the current mesh
  28652. */
  28653. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28654. /**
  28655. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28656. * Supports definition of mesh facing forward or backward.
  28657. * @param flipBack defines the flip
  28658. * @param twirlClockwise defines the twirl
  28659. * @param tiltRight defines the tilt
  28660. * @returns the new rotation vector
  28661. */
  28662. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28663. /**
  28664. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28665. * This means the mesh underlying bounding box and sphere are recomputed.
  28666. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28667. * @returns the current mesh
  28668. */
  28669. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28670. /** @hidden */
  28671. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28672. /** @hidden */
  28673. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28674. /** @hidden */
  28675. _updateBoundingInfo(): AbstractMesh;
  28676. /** @hidden */
  28677. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28678. /** @hidden */
  28679. protected _afterComputeWorldMatrix(): void;
  28680. /** @hidden */
  28681. get _effectiveMesh(): AbstractMesh;
  28682. /**
  28683. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28684. * A mesh is in the frustum if its bounding box intersects the frustum
  28685. * @param frustumPlanes defines the frustum to test
  28686. * @returns true if the mesh is in the frustum planes
  28687. */
  28688. isInFrustum(frustumPlanes: Plane[]): boolean;
  28689. /**
  28690. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28691. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28692. * @param frustumPlanes defines the frustum to test
  28693. * @returns true if the mesh is completely in the frustum planes
  28694. */
  28695. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28696. /**
  28697. * True if the mesh intersects another mesh or a SolidParticle object
  28698. * @param mesh defines a target mesh or SolidParticle to test
  28699. * @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)
  28700. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28701. * @returns true if there is an intersection
  28702. */
  28703. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28704. /**
  28705. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28706. * @param point defines the point to test
  28707. * @returns true if there is an intersection
  28708. */
  28709. intersectsPoint(point: Vector3): boolean;
  28710. /**
  28711. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28713. */
  28714. get checkCollisions(): boolean;
  28715. set checkCollisions(collisionEnabled: boolean);
  28716. /**
  28717. * Gets Collider object used to compute collisions (not physics)
  28718. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28719. */
  28720. get collider(): Nullable<Collider>;
  28721. /**
  28722. * Move the mesh using collision engine
  28723. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28724. * @param displacement defines the requested displacement vector
  28725. * @returns the current mesh
  28726. */
  28727. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28728. private _onCollisionPositionChange;
  28729. /** @hidden */
  28730. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28731. /** @hidden */
  28732. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28733. /** @hidden */
  28734. _checkCollision(collider: Collider): AbstractMesh;
  28735. /** @hidden */
  28736. _generatePointsArray(): boolean;
  28737. /**
  28738. * Checks if the passed Ray intersects with the mesh
  28739. * @param ray defines the ray to use
  28740. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28742. * @returns the picking info
  28743. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28744. */
  28745. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28746. /**
  28747. * Clones the current mesh
  28748. * @param name defines the mesh name
  28749. * @param newParent defines the new mesh parent
  28750. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28751. * @returns the new mesh
  28752. */
  28753. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28754. /**
  28755. * Disposes all the submeshes of the current meshnp
  28756. * @returns the current mesh
  28757. */
  28758. releaseSubMeshes(): AbstractMesh;
  28759. /**
  28760. * Releases resources associated with this abstract mesh.
  28761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28763. */
  28764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28765. /**
  28766. * Adds the passed mesh as a child to the current mesh
  28767. * @param mesh defines the child mesh
  28768. * @returns the current mesh
  28769. */
  28770. addChild(mesh: AbstractMesh): AbstractMesh;
  28771. /**
  28772. * Removes the passed mesh from the current mesh children list
  28773. * @param mesh defines the child mesh
  28774. * @returns the current mesh
  28775. */
  28776. removeChild(mesh: AbstractMesh): AbstractMesh;
  28777. /** @hidden */
  28778. private _initFacetData;
  28779. /**
  28780. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28781. * This method can be called within the render loop.
  28782. * 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
  28783. * @returns the current mesh
  28784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28785. */
  28786. updateFacetData(): AbstractMesh;
  28787. /**
  28788. * Returns the facetLocalNormals array.
  28789. * The normals are expressed in the mesh local spac
  28790. * @returns an array of Vector3
  28791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28792. */
  28793. getFacetLocalNormals(): Vector3[];
  28794. /**
  28795. * Returns the facetLocalPositions array.
  28796. * The facet positions are expressed in the mesh local space
  28797. * @returns an array of Vector3
  28798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28799. */
  28800. getFacetLocalPositions(): Vector3[];
  28801. /**
  28802. * Returns the facetLocalPartioning array
  28803. * @returns an array of array of numbers
  28804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28805. */
  28806. getFacetLocalPartitioning(): number[][];
  28807. /**
  28808. * Returns the i-th facet position in the world system.
  28809. * This method allocates a new Vector3 per call
  28810. * @param i defines the facet index
  28811. * @returns a new Vector3
  28812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28813. */
  28814. getFacetPosition(i: number): Vector3;
  28815. /**
  28816. * Sets the reference Vector3 with the i-th facet position in the world system
  28817. * @param i defines the facet index
  28818. * @param ref defines the target vector
  28819. * @returns the current mesh
  28820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28821. */
  28822. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28823. /**
  28824. * Returns the i-th facet normal in the world system.
  28825. * This method allocates a new Vector3 per call
  28826. * @param i defines the facet index
  28827. * @returns a new Vector3
  28828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28829. */
  28830. getFacetNormal(i: number): Vector3;
  28831. /**
  28832. * Sets the reference Vector3 with the i-th facet normal in the world system
  28833. * @param i defines the facet index
  28834. * @param ref defines the target vector
  28835. * @returns the current mesh
  28836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28837. */
  28838. getFacetNormalToRef(i: number, ref: Vector3): this;
  28839. /**
  28840. * 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)
  28841. * @param x defines x coordinate
  28842. * @param y defines y coordinate
  28843. * @param z defines z coordinate
  28844. * @returns the array of facet indexes
  28845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28846. */
  28847. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28848. /**
  28849. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28850. * @param projected sets as the (x,y,z) world 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. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28860. /**
  28861. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28862. * @param projected sets as the (x,y,z) local projection on the facet
  28863. * @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
  28864. * @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
  28865. * @param x defines x coordinate
  28866. * @param y defines y coordinate
  28867. * @param z defines z coordinate
  28868. * @returns the face index if found (or null instead)
  28869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28870. */
  28871. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28872. /**
  28873. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28874. * @returns the parameters
  28875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28876. */
  28877. getFacetDataParameters(): any;
  28878. /**
  28879. * Disables the feature FacetData and frees the related memory
  28880. * @returns the current mesh
  28881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28882. */
  28883. disableFacetData(): AbstractMesh;
  28884. /**
  28885. * Updates the AbstractMesh indices array
  28886. * @param indices defines the data source
  28887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28888. * @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)
  28889. * @returns the current mesh
  28890. */
  28891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28892. /**
  28893. * Creates new normals data for the mesh
  28894. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28895. * @returns the current mesh
  28896. */
  28897. createNormals(updatable: boolean): AbstractMesh;
  28898. /**
  28899. * Align the mesh with a normal
  28900. * @param normal defines the normal to use
  28901. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28902. * @returns the current mesh
  28903. */
  28904. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28905. /** @hidden */
  28906. _checkOcclusionQuery(): boolean;
  28907. /**
  28908. * Disables the mesh edge rendering mode
  28909. * @returns the currentAbstractMesh
  28910. */
  28911. disableEdgesRendering(): AbstractMesh;
  28912. /**
  28913. * Enables the edge rendering mode on the mesh.
  28914. * This mode makes the mesh edges visible
  28915. * @param epsilon defines the maximal distance between two angles to detect a face
  28916. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28917. * @returns the currentAbstractMesh
  28918. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28919. */
  28920. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28921. }
  28922. }
  28923. declare module BABYLON {
  28924. /**
  28925. * Interface used to define ActionEvent
  28926. */
  28927. export interface IActionEvent {
  28928. /** The mesh or sprite that triggered the action */
  28929. source: any;
  28930. /** The X mouse cursor position at the time of the event */
  28931. pointerX: number;
  28932. /** The Y mouse cursor position at the time of the event */
  28933. pointerY: number;
  28934. /** The mesh that is currently pointed at (can be null) */
  28935. meshUnderPointer: Nullable<AbstractMesh>;
  28936. /** the original (browser) event that triggered the ActionEvent */
  28937. sourceEvent?: any;
  28938. /** additional data for the event */
  28939. additionalData?: any;
  28940. }
  28941. /**
  28942. * ActionEvent is the event being sent when an action is triggered.
  28943. */
  28944. export class ActionEvent implements IActionEvent {
  28945. /** The mesh or sprite that triggered the action */
  28946. source: any;
  28947. /** The X mouse cursor position at the time of the event */
  28948. pointerX: number;
  28949. /** The Y mouse cursor position at the time of the event */
  28950. pointerY: number;
  28951. /** The mesh that is currently pointed at (can be null) */
  28952. meshUnderPointer: Nullable<AbstractMesh>;
  28953. /** the original (browser) event that triggered the ActionEvent */
  28954. sourceEvent?: any;
  28955. /** additional data for the event */
  28956. additionalData?: any;
  28957. /**
  28958. * Creates a new ActionEvent
  28959. * @param source The mesh or sprite that triggered the action
  28960. * @param pointerX The X mouse cursor position at the time of the event
  28961. * @param pointerY The Y mouse cursor position at the time of the event
  28962. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28963. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28964. * @param additionalData additional data for the event
  28965. */
  28966. constructor(
  28967. /** The mesh or sprite that triggered the action */
  28968. source: any,
  28969. /** The X mouse cursor position at the time of the event */
  28970. pointerX: number,
  28971. /** The Y mouse cursor position at the time of the event */
  28972. pointerY: number,
  28973. /** The mesh that is currently pointed at (can be null) */
  28974. meshUnderPointer: Nullable<AbstractMesh>,
  28975. /** the original (browser) event that triggered the ActionEvent */
  28976. sourceEvent?: any,
  28977. /** additional data for the event */
  28978. additionalData?: any);
  28979. /**
  28980. * Helper function to auto-create an ActionEvent from a source mesh.
  28981. * @param source The source mesh that triggered the event
  28982. * @param evt The original (browser) event
  28983. * @param additionalData additional data for the event
  28984. * @returns the new ActionEvent
  28985. */
  28986. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28987. /**
  28988. * Helper function to auto-create an ActionEvent from a source sprite
  28989. * @param source The source sprite that triggered the event
  28990. * @param scene Scene associated with the sprite
  28991. * @param evt The original (browser) event
  28992. * @param additionalData additional data for the event
  28993. * @returns the new ActionEvent
  28994. */
  28995. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28996. /**
  28997. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28998. * @param scene the scene where the event occurred
  28999. * @param evt The original (browser) event
  29000. * @returns the new ActionEvent
  29001. */
  29002. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29003. /**
  29004. * Helper function to auto-create an ActionEvent from a primitive
  29005. * @param prim defines the target primitive
  29006. * @param pointerPos defines the pointer position
  29007. * @param evt The original (browser) event
  29008. * @param additionalData additional data for the event
  29009. * @returns the new ActionEvent
  29010. */
  29011. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29012. }
  29013. }
  29014. declare module BABYLON {
  29015. /**
  29016. * Abstract class used to decouple action Manager from scene and meshes.
  29017. * Do not instantiate.
  29018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29019. */
  29020. export abstract class AbstractActionManager implements IDisposable {
  29021. /** Gets the list of active triggers */
  29022. static Triggers: {
  29023. [key: string]: number;
  29024. };
  29025. /** Gets the cursor to use when hovering items */
  29026. hoverCursor: string;
  29027. /** Gets the list of actions */
  29028. actions: IAction[];
  29029. /**
  29030. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29031. */
  29032. isRecursive: boolean;
  29033. /**
  29034. * Releases all associated resources
  29035. */
  29036. abstract dispose(): void;
  29037. /**
  29038. * Does this action manager has pointer triggers
  29039. */
  29040. abstract get hasPointerTriggers(): boolean;
  29041. /**
  29042. * Does this action manager has pick triggers
  29043. */
  29044. abstract get hasPickTriggers(): boolean;
  29045. /**
  29046. * Process a specific trigger
  29047. * @param trigger defines the trigger to process
  29048. * @param evt defines the event details to be processed
  29049. */
  29050. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29051. /**
  29052. * Does this action manager handles actions of any of the given triggers
  29053. * @param triggers defines the triggers to be tested
  29054. * @return a boolean indicating whether one (or more) of the triggers is handled
  29055. */
  29056. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29057. /**
  29058. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29059. * speed.
  29060. * @param triggerA defines the trigger to be tested
  29061. * @param triggerB defines the trigger to be tested
  29062. * @return a boolean indicating whether one (or more) of the triggers is handled
  29063. */
  29064. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29065. /**
  29066. * Does this action manager handles actions of a given trigger
  29067. * @param trigger defines the trigger to be tested
  29068. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29069. * @return whether the trigger is handled
  29070. */
  29071. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29072. /**
  29073. * Serialize this manager to a JSON object
  29074. * @param name defines the property name to store this manager
  29075. * @returns a JSON representation of this manager
  29076. */
  29077. abstract serialize(name: string): any;
  29078. /**
  29079. * Registers an action to this action manager
  29080. * @param action defines the action to be registered
  29081. * @return the action amended (prepared) after registration
  29082. */
  29083. abstract registerAction(action: IAction): Nullable<IAction>;
  29084. /**
  29085. * Unregisters an action to this action manager
  29086. * @param action defines the action to be unregistered
  29087. * @return a boolean indicating whether the action has been unregistered
  29088. */
  29089. abstract unregisterAction(action: IAction): Boolean;
  29090. /**
  29091. * Does exist one action manager with at least one trigger
  29092. **/
  29093. static get HasTriggers(): boolean;
  29094. /**
  29095. * Does exist one action manager with at least one pick trigger
  29096. **/
  29097. static get HasPickTriggers(): boolean;
  29098. /**
  29099. * Does exist one action manager that handles actions of a given trigger
  29100. * @param trigger defines the trigger to be tested
  29101. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29102. **/
  29103. static HasSpecificTrigger(trigger: number): boolean;
  29104. }
  29105. }
  29106. declare module BABYLON {
  29107. /**
  29108. * Defines how a node can be built from a string name.
  29109. */
  29110. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29111. /**
  29112. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29113. */
  29114. export class Node implements IBehaviorAware<Node> {
  29115. /** @hidden */
  29116. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29117. private static _NodeConstructors;
  29118. /**
  29119. * Add a new node constructor
  29120. * @param type defines the type name of the node to construct
  29121. * @param constructorFunc defines the constructor function
  29122. */
  29123. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29124. /**
  29125. * Returns a node constructor based on type name
  29126. * @param type defines the type name
  29127. * @param name defines the new node name
  29128. * @param scene defines the hosting scene
  29129. * @param options defines optional options to transmit to constructors
  29130. * @returns the new constructor or null
  29131. */
  29132. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29133. /**
  29134. * Gets or sets the name of the node
  29135. */
  29136. name: string;
  29137. /**
  29138. * Gets or sets the id of the node
  29139. */
  29140. id: string;
  29141. /**
  29142. * Gets or sets the unique id of the node
  29143. */
  29144. uniqueId: number;
  29145. /**
  29146. * Gets or sets a string used to store user defined state for the node
  29147. */
  29148. state: string;
  29149. /**
  29150. * Gets or sets an object used to store user defined information for the node
  29151. */
  29152. metadata: any;
  29153. /**
  29154. * For internal use only. Please do not use.
  29155. */
  29156. reservedDataStore: any;
  29157. /**
  29158. * List of inspectable custom properties (used by the Inspector)
  29159. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29160. */
  29161. inspectableCustomProperties: IInspectable[];
  29162. private _doNotSerialize;
  29163. /**
  29164. * Gets or sets a boolean used to define if the node must be serialized
  29165. */
  29166. get doNotSerialize(): boolean;
  29167. set doNotSerialize(value: boolean);
  29168. /** @hidden */
  29169. _isDisposed: boolean;
  29170. /**
  29171. * Gets a list of Animations associated with the node
  29172. */
  29173. animations: Animation[];
  29174. protected _ranges: {
  29175. [name: string]: Nullable<AnimationRange>;
  29176. };
  29177. /**
  29178. * Callback raised when the node is ready to be used
  29179. */
  29180. onReady: Nullable<(node: Node) => void>;
  29181. private _isEnabled;
  29182. private _isParentEnabled;
  29183. private _isReady;
  29184. /** @hidden */
  29185. _currentRenderId: number;
  29186. private _parentUpdateId;
  29187. /** @hidden */
  29188. _childUpdateId: number;
  29189. /** @hidden */
  29190. _waitingParentId: Nullable<string>;
  29191. /** @hidden */
  29192. _scene: Scene;
  29193. /** @hidden */
  29194. _cache: any;
  29195. private _parentNode;
  29196. private _children;
  29197. /** @hidden */
  29198. _worldMatrix: Matrix;
  29199. /** @hidden */
  29200. _worldMatrixDeterminant: number;
  29201. /** @hidden */
  29202. _worldMatrixDeterminantIsDirty: boolean;
  29203. /** @hidden */
  29204. private _sceneRootNodesIndex;
  29205. /**
  29206. * Gets a boolean indicating if the node has been disposed
  29207. * @returns true if the node was disposed
  29208. */
  29209. isDisposed(): boolean;
  29210. /**
  29211. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29212. * @see https://doc.babylonjs.com/how_to/parenting
  29213. */
  29214. set parent(parent: Nullable<Node>);
  29215. get parent(): Nullable<Node>;
  29216. /** @hidden */
  29217. _addToSceneRootNodes(): void;
  29218. /** @hidden */
  29219. _removeFromSceneRootNodes(): void;
  29220. private _animationPropertiesOverride;
  29221. /**
  29222. * Gets or sets the animation properties override
  29223. */
  29224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29226. /**
  29227. * Gets a string idenfifying the name of the class
  29228. * @returns "Node" string
  29229. */
  29230. getClassName(): string;
  29231. /** @hidden */
  29232. readonly _isNode: boolean;
  29233. /**
  29234. * An event triggered when the mesh is disposed
  29235. */
  29236. onDisposeObservable: Observable<Node>;
  29237. private _onDisposeObserver;
  29238. /**
  29239. * Sets a callback that will be raised when the node will be disposed
  29240. */
  29241. set onDispose(callback: () => void);
  29242. /**
  29243. * Creates a new Node
  29244. * @param name the name and id to be given to this node
  29245. * @param scene the scene this node will be added to
  29246. */
  29247. constructor(name: string, scene?: Nullable<Scene>);
  29248. /**
  29249. * Gets the scene of the node
  29250. * @returns a scene
  29251. */
  29252. getScene(): Scene;
  29253. /**
  29254. * Gets the engine of the node
  29255. * @returns a Engine
  29256. */
  29257. getEngine(): Engine;
  29258. private _behaviors;
  29259. /**
  29260. * Attach a behavior to the node
  29261. * @see http://doc.babylonjs.com/features/behaviour
  29262. * @param behavior defines the behavior to attach
  29263. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29264. * @returns the current Node
  29265. */
  29266. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29267. /**
  29268. * Remove an attached behavior
  29269. * @see http://doc.babylonjs.com/features/behaviour
  29270. * @param behavior defines the behavior to attach
  29271. * @returns the current Node
  29272. */
  29273. removeBehavior(behavior: Behavior<Node>): Node;
  29274. /**
  29275. * Gets the list of attached behaviors
  29276. * @see http://doc.babylonjs.com/features/behaviour
  29277. */
  29278. get behaviors(): Behavior<Node>[];
  29279. /**
  29280. * Gets an attached behavior by name
  29281. * @param name defines the name of the behavior to look for
  29282. * @see http://doc.babylonjs.com/features/behaviour
  29283. * @returns null if behavior was not found else the requested behavior
  29284. */
  29285. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29286. /**
  29287. * Returns the latest update of the World matrix
  29288. * @returns a Matrix
  29289. */
  29290. getWorldMatrix(): Matrix;
  29291. /** @hidden */
  29292. _getWorldMatrixDeterminant(): number;
  29293. /**
  29294. * Returns directly the latest state of the mesh World matrix.
  29295. * A Matrix is returned.
  29296. */
  29297. get worldMatrixFromCache(): Matrix;
  29298. /** @hidden */
  29299. _initCache(): void;
  29300. /** @hidden */
  29301. updateCache(force?: boolean): void;
  29302. /** @hidden */
  29303. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29304. /** @hidden */
  29305. _updateCache(ignoreParentClass?: boolean): void;
  29306. /** @hidden */
  29307. _isSynchronized(): boolean;
  29308. /** @hidden */
  29309. _markSyncedWithParent(): void;
  29310. /** @hidden */
  29311. isSynchronizedWithParent(): boolean;
  29312. /** @hidden */
  29313. isSynchronized(): boolean;
  29314. /**
  29315. * Is this node ready to be used/rendered
  29316. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29317. * @return true if the node is ready
  29318. */
  29319. isReady(completeCheck?: boolean): boolean;
  29320. /**
  29321. * Is this node enabled?
  29322. * 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
  29323. * @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
  29324. * @return whether this node (and its parent) is enabled
  29325. */
  29326. isEnabled(checkAncestors?: boolean): boolean;
  29327. /** @hidden */
  29328. protected _syncParentEnabledState(): void;
  29329. /**
  29330. * Set the enabled state of this node
  29331. * @param value defines the new enabled state
  29332. */
  29333. setEnabled(value: boolean): void;
  29334. /**
  29335. * Is this node a descendant of the given node?
  29336. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29337. * @param ancestor defines the parent node to inspect
  29338. * @returns a boolean indicating if this node is a descendant of the given node
  29339. */
  29340. isDescendantOf(ancestor: Node): boolean;
  29341. /** @hidden */
  29342. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29343. /**
  29344. * Will return all nodes that have this node as ascendant
  29345. * @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
  29346. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29347. * @return all children nodes of all types
  29348. */
  29349. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29350. /**
  29351. * Get all child-meshes of this node
  29352. * @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)
  29353. * @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
  29354. * @returns an array of AbstractMesh
  29355. */
  29356. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29357. /**
  29358. * Get all direct children of this node
  29359. * @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
  29360. * @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)
  29361. * @returns an array of Node
  29362. */
  29363. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29364. /** @hidden */
  29365. _setReady(state: boolean): void;
  29366. /**
  29367. * Get an animation by name
  29368. * @param name defines the name of the animation to look for
  29369. * @returns null if not found else the requested animation
  29370. */
  29371. getAnimationByName(name: string): Nullable<Animation>;
  29372. /**
  29373. * Creates an animation range for this node
  29374. * @param name defines the name of the range
  29375. * @param from defines the starting key
  29376. * @param to defines the end key
  29377. */
  29378. createAnimationRange(name: string, from: number, to: number): void;
  29379. /**
  29380. * Delete a specific animation range
  29381. * @param name defines the name of the range to delete
  29382. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29383. */
  29384. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29385. /**
  29386. * Get an animation range by name
  29387. * @param name defines the name of the animation range to look for
  29388. * @returns null if not found else the requested animation range
  29389. */
  29390. getAnimationRange(name: string): Nullable<AnimationRange>;
  29391. /**
  29392. * Gets the list of all animation ranges defined on this node
  29393. * @returns an array
  29394. */
  29395. getAnimationRanges(): Nullable<AnimationRange>[];
  29396. /**
  29397. * Will start the animation sequence
  29398. * @param name defines the range frames for animation sequence
  29399. * @param loop defines if the animation should loop (false by default)
  29400. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29401. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29402. * @returns the object created for this animation. If range does not exist, it will return null
  29403. */
  29404. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29405. /**
  29406. * Serialize animation ranges into a JSON compatible object
  29407. * @returns serialization object
  29408. */
  29409. serializeAnimationRanges(): any;
  29410. /**
  29411. * Computes the world matrix of the node
  29412. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29413. * @returns the world matrix
  29414. */
  29415. computeWorldMatrix(force?: boolean): Matrix;
  29416. /**
  29417. * Releases resources associated with this node.
  29418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29420. */
  29421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29422. /**
  29423. * Parse animation range data from a serialization object and store them into a given node
  29424. * @param node defines where to store the animation ranges
  29425. * @param parsedNode defines the serialization object to read data from
  29426. * @param scene defines the hosting scene
  29427. */
  29428. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29429. /**
  29430. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29431. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29432. * @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
  29433. * @returns the new bounding vectors
  29434. */
  29435. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29436. min: Vector3;
  29437. max: Vector3;
  29438. };
  29439. }
  29440. }
  29441. declare module BABYLON {
  29442. /**
  29443. * @hidden
  29444. */
  29445. export class _IAnimationState {
  29446. key: number;
  29447. repeatCount: number;
  29448. workValue?: any;
  29449. loopMode?: number;
  29450. offsetValue?: any;
  29451. highLimitValue?: any;
  29452. }
  29453. /**
  29454. * Class used to store any kind of animation
  29455. */
  29456. export class Animation {
  29457. /**Name of the animation */
  29458. name: string;
  29459. /**Property to animate */
  29460. targetProperty: string;
  29461. /**The frames per second of the animation */
  29462. framePerSecond: number;
  29463. /**The data type of the animation */
  29464. dataType: number;
  29465. /**The loop mode of the animation */
  29466. loopMode?: number | undefined;
  29467. /**Specifies if blending should be enabled */
  29468. enableBlending?: boolean | undefined;
  29469. /**
  29470. * Use matrix interpolation instead of using direct key value when animating matrices
  29471. */
  29472. static AllowMatricesInterpolation: boolean;
  29473. /**
  29474. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29475. */
  29476. static AllowMatrixDecomposeForInterpolation: boolean;
  29477. /**
  29478. * Stores the key frames of the animation
  29479. */
  29480. private _keys;
  29481. /**
  29482. * Stores the easing function of the animation
  29483. */
  29484. private _easingFunction;
  29485. /**
  29486. * @hidden Internal use only
  29487. */
  29488. _runtimeAnimations: RuntimeAnimation[];
  29489. /**
  29490. * The set of event that will be linked to this animation
  29491. */
  29492. private _events;
  29493. /**
  29494. * Stores an array of target property paths
  29495. */
  29496. targetPropertyPath: string[];
  29497. /**
  29498. * Stores the blending speed of the animation
  29499. */
  29500. blendingSpeed: number;
  29501. /**
  29502. * Stores the animation ranges for the animation
  29503. */
  29504. private _ranges;
  29505. /**
  29506. * @hidden Internal use
  29507. */
  29508. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29509. /**
  29510. * Sets up an animation
  29511. * @param property The property to animate
  29512. * @param animationType The animation type to apply
  29513. * @param framePerSecond The frames per second of the animation
  29514. * @param easingFunction The easing function used in the animation
  29515. * @returns The created animation
  29516. */
  29517. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29518. /**
  29519. * Create and start an animation on a node
  29520. * @param name defines the name of the global animation that will be run on all nodes
  29521. * @param node defines the root node where the animation will take place
  29522. * @param targetProperty defines property to animate
  29523. * @param framePerSecond defines the number of frame per second yo use
  29524. * @param totalFrame defines the number of frames in total
  29525. * @param from defines the initial value
  29526. * @param to defines the final value
  29527. * @param loopMode defines which loop mode you want to use (off by default)
  29528. * @param easingFunction defines the easing function to use (linear by default)
  29529. * @param onAnimationEnd defines the callback to call when animation end
  29530. * @returns the animatable created for this animation
  29531. */
  29532. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29533. /**
  29534. * Create and start an animation on a node and its descendants
  29535. * @param name defines the name of the global animation that will be run on all nodes
  29536. * @param node defines the root node where the animation will take place
  29537. * @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
  29538. * @param targetProperty defines property to animate
  29539. * @param framePerSecond defines the number of frame per second to use
  29540. * @param totalFrame defines the number of frames in total
  29541. * @param from defines the initial value
  29542. * @param to defines the final value
  29543. * @param loopMode defines which loop mode you want to use (off by default)
  29544. * @param easingFunction defines the easing function to use (linear by default)
  29545. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29546. * @returns the list of animatables created for all nodes
  29547. * @example https://www.babylonjs-playground.com/#MH0VLI
  29548. */
  29549. 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[]>;
  29550. /**
  29551. * Creates a new animation, merges it with the existing animations and starts it
  29552. * @param name Name of the animation
  29553. * @param node Node which contains the scene that begins the animations
  29554. * @param targetProperty Specifies which property to animate
  29555. * @param framePerSecond The frames per second of the animation
  29556. * @param totalFrame The total number of frames
  29557. * @param from The frame at the beginning of the animation
  29558. * @param to The frame at the end of the animation
  29559. * @param loopMode Specifies the loop mode of the animation
  29560. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29561. * @param onAnimationEnd Callback to run once the animation is complete
  29562. * @returns Nullable animation
  29563. */
  29564. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29565. /**
  29566. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29567. * @param sourceAnimation defines the Animation containing keyframes to convert
  29568. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29569. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29570. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29571. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29572. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29573. */
  29574. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29575. /**
  29576. * Transition property of an host to the target Value
  29577. * @param property The property to transition
  29578. * @param targetValue The target Value of the property
  29579. * @param host The object where the property to animate belongs
  29580. * @param scene Scene used to run the animation
  29581. * @param frameRate Framerate (in frame/s) to use
  29582. * @param transition The transition type we want to use
  29583. * @param duration The duration of the animation, in milliseconds
  29584. * @param onAnimationEnd Callback trigger at the end of the animation
  29585. * @returns Nullable animation
  29586. */
  29587. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29588. /**
  29589. * Return the array of runtime animations currently using this animation
  29590. */
  29591. get runtimeAnimations(): RuntimeAnimation[];
  29592. /**
  29593. * Specifies if any of the runtime animations are currently running
  29594. */
  29595. get hasRunningRuntimeAnimations(): boolean;
  29596. /**
  29597. * Initializes the animation
  29598. * @param name Name of the animation
  29599. * @param targetProperty Property to animate
  29600. * @param framePerSecond The frames per second of the animation
  29601. * @param dataType The data type of the animation
  29602. * @param loopMode The loop mode of the animation
  29603. * @param enableBlending Specifies if blending should be enabled
  29604. */
  29605. constructor(
  29606. /**Name of the animation */
  29607. name: string,
  29608. /**Property to animate */
  29609. targetProperty: string,
  29610. /**The frames per second of the animation */
  29611. framePerSecond: number,
  29612. /**The data type of the animation */
  29613. dataType: number,
  29614. /**The loop mode of the animation */
  29615. loopMode?: number | undefined,
  29616. /**Specifies if blending should be enabled */
  29617. enableBlending?: boolean | undefined);
  29618. /**
  29619. * Converts the animation to a string
  29620. * @param fullDetails support for multiple levels of logging within scene loading
  29621. * @returns String form of the animation
  29622. */
  29623. toString(fullDetails?: boolean): string;
  29624. /**
  29625. * Add an event to this animation
  29626. * @param event Event to add
  29627. */
  29628. addEvent(event: AnimationEvent): void;
  29629. /**
  29630. * Remove all events found at the given frame
  29631. * @param frame The frame to remove events from
  29632. */
  29633. removeEvents(frame: number): void;
  29634. /**
  29635. * Retrieves all the events from the animation
  29636. * @returns Events from the animation
  29637. */
  29638. getEvents(): AnimationEvent[];
  29639. /**
  29640. * Creates an animation range
  29641. * @param name Name of the animation range
  29642. * @param from Starting frame of the animation range
  29643. * @param to Ending frame of the animation
  29644. */
  29645. createRange(name: string, from: number, to: number): void;
  29646. /**
  29647. * Deletes an animation range by name
  29648. * @param name Name of the animation range to delete
  29649. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29650. */
  29651. deleteRange(name: string, deleteFrames?: boolean): void;
  29652. /**
  29653. * Gets the animation range by name, or null if not defined
  29654. * @param name Name of the animation range
  29655. * @returns Nullable animation range
  29656. */
  29657. getRange(name: string): Nullable<AnimationRange>;
  29658. /**
  29659. * Gets the key frames from the animation
  29660. * @returns The key frames of the animation
  29661. */
  29662. getKeys(): Array<IAnimationKey>;
  29663. /**
  29664. * Gets the highest frame rate of the animation
  29665. * @returns Highest frame rate of the animation
  29666. */
  29667. getHighestFrame(): number;
  29668. /**
  29669. * Gets the easing function of the animation
  29670. * @returns Easing function of the animation
  29671. */
  29672. getEasingFunction(): IEasingFunction;
  29673. /**
  29674. * Sets the easing function of the animation
  29675. * @param easingFunction A custom mathematical formula for animation
  29676. */
  29677. setEasingFunction(easingFunction: EasingFunction): void;
  29678. /**
  29679. * Interpolates a scalar linearly
  29680. * @param startValue Start value of the animation curve
  29681. * @param endValue End value of the animation curve
  29682. * @param gradient Scalar amount to interpolate
  29683. * @returns Interpolated scalar value
  29684. */
  29685. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29686. /**
  29687. * Interpolates a scalar cubically
  29688. * @param startValue Start value of the animation curve
  29689. * @param outTangent End tangent of the animation
  29690. * @param endValue End value of the animation curve
  29691. * @param inTangent Start tangent of the animation curve
  29692. * @param gradient Scalar amount to interpolate
  29693. * @returns Interpolated scalar value
  29694. */
  29695. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29696. /**
  29697. * Interpolates a quaternion using a spherical linear interpolation
  29698. * @param startValue Start value of the animation curve
  29699. * @param endValue End value of the animation curve
  29700. * @param gradient Scalar amount to interpolate
  29701. * @returns Interpolated quaternion value
  29702. */
  29703. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29704. /**
  29705. * Interpolates a quaternion cubically
  29706. * @param startValue Start value of the animation curve
  29707. * @param outTangent End tangent of the animation curve
  29708. * @param endValue End value of the animation curve
  29709. * @param inTangent Start tangent of the animation curve
  29710. * @param gradient Scalar amount to interpolate
  29711. * @returns Interpolated quaternion value
  29712. */
  29713. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29714. /**
  29715. * Interpolates a Vector3 linearl
  29716. * @param startValue Start value of the animation curve
  29717. * @param endValue End value of the animation curve
  29718. * @param gradient Scalar amount to interpolate
  29719. * @returns Interpolated scalar value
  29720. */
  29721. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29722. /**
  29723. * Interpolates a Vector3 cubically
  29724. * @param startValue Start value of the animation curve
  29725. * @param outTangent End tangent of the animation
  29726. * @param endValue End value of the animation curve
  29727. * @param inTangent Start tangent of the animation curve
  29728. * @param gradient Scalar amount to interpolate
  29729. * @returns InterpolatedVector3 value
  29730. */
  29731. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29732. /**
  29733. * Interpolates a Vector2 linearly
  29734. * @param startValue Start value of the animation curve
  29735. * @param endValue End value of the animation curve
  29736. * @param gradient Scalar amount to interpolate
  29737. * @returns Interpolated Vector2 value
  29738. */
  29739. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29740. /**
  29741. * Interpolates a Vector2 cubically
  29742. * @param startValue Start value of the animation curve
  29743. * @param outTangent End tangent of the animation
  29744. * @param endValue End value of the animation curve
  29745. * @param inTangent Start tangent of the animation curve
  29746. * @param gradient Scalar amount to interpolate
  29747. * @returns Interpolated Vector2 value
  29748. */
  29749. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29750. /**
  29751. * Interpolates a size linearly
  29752. * @param startValue Start value of the animation curve
  29753. * @param endValue End value of the animation curve
  29754. * @param gradient Scalar amount to interpolate
  29755. * @returns Interpolated Size value
  29756. */
  29757. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29758. /**
  29759. * Interpolates a Color3 linearly
  29760. * @param startValue Start value of the animation curve
  29761. * @param endValue End value of the animation curve
  29762. * @param gradient Scalar amount to interpolate
  29763. * @returns Interpolated Color3 value
  29764. */
  29765. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29766. /**
  29767. * Interpolates a Color4 linearly
  29768. * @param startValue Start value of the animation curve
  29769. * @param endValue End value of the animation curve
  29770. * @param gradient Scalar amount to interpolate
  29771. * @returns Interpolated Color3 value
  29772. */
  29773. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29774. /**
  29775. * @hidden Internal use only
  29776. */
  29777. _getKeyValue(value: any): any;
  29778. /**
  29779. * @hidden Internal use only
  29780. */
  29781. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29782. /**
  29783. * Defines the function to use to interpolate matrices
  29784. * @param startValue defines the start matrix
  29785. * @param endValue defines the end matrix
  29786. * @param gradient defines the gradient between both matrices
  29787. * @param result defines an optional target matrix where to store the interpolation
  29788. * @returns the interpolated matrix
  29789. */
  29790. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29791. /**
  29792. * Makes a copy of the animation
  29793. * @returns Cloned animation
  29794. */
  29795. clone(): Animation;
  29796. /**
  29797. * Sets the key frames of the animation
  29798. * @param values The animation key frames to set
  29799. */
  29800. setKeys(values: Array<IAnimationKey>): void;
  29801. /**
  29802. * Serializes the animation to an object
  29803. * @returns Serialized object
  29804. */
  29805. serialize(): any;
  29806. /**
  29807. * Float animation type
  29808. */
  29809. static readonly ANIMATIONTYPE_FLOAT: number;
  29810. /**
  29811. * Vector3 animation type
  29812. */
  29813. static readonly ANIMATIONTYPE_VECTOR3: number;
  29814. /**
  29815. * Quaternion animation type
  29816. */
  29817. static readonly ANIMATIONTYPE_QUATERNION: number;
  29818. /**
  29819. * Matrix animation type
  29820. */
  29821. static readonly ANIMATIONTYPE_MATRIX: number;
  29822. /**
  29823. * Color3 animation type
  29824. */
  29825. static readonly ANIMATIONTYPE_COLOR3: number;
  29826. /**
  29827. * Color3 animation type
  29828. */
  29829. static readonly ANIMATIONTYPE_COLOR4: number;
  29830. /**
  29831. * Vector2 animation type
  29832. */
  29833. static readonly ANIMATIONTYPE_VECTOR2: number;
  29834. /**
  29835. * Size animation type
  29836. */
  29837. static readonly ANIMATIONTYPE_SIZE: number;
  29838. /**
  29839. * Relative Loop Mode
  29840. */
  29841. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29842. /**
  29843. * Cycle Loop Mode
  29844. */
  29845. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29846. /**
  29847. * Constant Loop Mode
  29848. */
  29849. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29850. /** @hidden */
  29851. static _UniversalLerp(left: any, right: any, amount: number): any;
  29852. /**
  29853. * Parses an animation object and creates an animation
  29854. * @param parsedAnimation Parsed animation object
  29855. * @returns Animation object
  29856. */
  29857. static Parse(parsedAnimation: any): Animation;
  29858. /**
  29859. * Appends the serialized animations from the source animations
  29860. * @param source Source containing the animations
  29861. * @param destination Target to store the animations
  29862. */
  29863. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29864. }
  29865. }
  29866. declare module BABYLON {
  29867. /**
  29868. * Interface containing an array of animations
  29869. */
  29870. export interface IAnimatable {
  29871. /**
  29872. * Array of animations
  29873. */
  29874. animations: Nullable<Array<Animation>>;
  29875. }
  29876. }
  29877. declare module BABYLON {
  29878. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29879. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29880. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29881. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29882. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29883. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29884. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29885. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29886. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29887. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29888. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29889. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29890. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29891. /**
  29892. * Decorator used to define property that can be serialized as reference to a camera
  29893. * @param sourceName defines the name of the property to decorate
  29894. */
  29895. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29896. /**
  29897. * Class used to help serialization objects
  29898. */
  29899. export class SerializationHelper {
  29900. /** @hidden */
  29901. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29902. /** @hidden */
  29903. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29904. /** @hidden */
  29905. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29906. /** @hidden */
  29907. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29908. /**
  29909. * Appends the serialized animations from the source animations
  29910. * @param source Source containing the animations
  29911. * @param destination Target to store the animations
  29912. */
  29913. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29914. /**
  29915. * Static function used to serialized a specific entity
  29916. * @param entity defines the entity to serialize
  29917. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29918. * @returns a JSON compatible object representing the serialization of the entity
  29919. */
  29920. static Serialize<T>(entity: T, serializationObject?: any): any;
  29921. /**
  29922. * Creates a new entity from a serialization data object
  29923. * @param creationFunction defines a function used to instanciated the new entity
  29924. * @param source defines the source serialization data
  29925. * @param scene defines the hosting scene
  29926. * @param rootUrl defines the root url for resources
  29927. * @returns a new entity
  29928. */
  29929. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29930. /**
  29931. * Clones an object
  29932. * @param creationFunction defines the function used to instanciate the new object
  29933. * @param source defines the source object
  29934. * @returns the cloned object
  29935. */
  29936. static Clone<T>(creationFunction: () => T, source: T): T;
  29937. /**
  29938. * Instanciates a new object based on a source one (some data will be shared between both object)
  29939. * @param creationFunction defines the function used to instanciate the new object
  29940. * @param source defines the source object
  29941. * @returns the new object
  29942. */
  29943. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29944. }
  29945. }
  29946. declare module BABYLON {
  29947. /**
  29948. * Class used to manipulate GUIDs
  29949. */
  29950. export class GUID {
  29951. /**
  29952. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29953. * Be aware Math.random() could cause collisions, but:
  29954. * "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"
  29955. * @returns a pseudo random id
  29956. */
  29957. static RandomId(): string;
  29958. }
  29959. }
  29960. declare module BABYLON {
  29961. /**
  29962. * Base class of all the textures in babylon.
  29963. * It groups all the common properties the materials, post process, lights... might need
  29964. * in order to make a correct use of the texture.
  29965. */
  29966. export class BaseTexture implements IAnimatable {
  29967. /**
  29968. * Default anisotropic filtering level for the application.
  29969. * It is set to 4 as a good tradeoff between perf and quality.
  29970. */
  29971. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29972. /**
  29973. * Gets or sets the unique id of the texture
  29974. */
  29975. uniqueId: number;
  29976. /**
  29977. * Define the name of the texture.
  29978. */
  29979. name: string;
  29980. /**
  29981. * Gets or sets an object used to store user defined information.
  29982. */
  29983. metadata: any;
  29984. /**
  29985. * For internal use only. Please do not use.
  29986. */
  29987. reservedDataStore: any;
  29988. private _hasAlpha;
  29989. /**
  29990. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29991. */
  29992. set hasAlpha(value: boolean);
  29993. get hasAlpha(): boolean;
  29994. /**
  29995. * Defines if the alpha value should be determined via the rgb values.
  29996. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29997. */
  29998. getAlphaFromRGB: boolean;
  29999. /**
  30000. * Intensity or strength of the texture.
  30001. * It is commonly used by materials to fine tune the intensity of the texture
  30002. */
  30003. level: number;
  30004. /**
  30005. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30006. * This is part of the texture as textures usually maps to one uv set.
  30007. */
  30008. coordinatesIndex: number;
  30009. private _coordinatesMode;
  30010. /**
  30011. * How a texture is mapped.
  30012. *
  30013. * | Value | Type | Description |
  30014. * | ----- | ----------------------------------- | ----------- |
  30015. * | 0 | EXPLICIT_MODE | |
  30016. * | 1 | SPHERICAL_MODE | |
  30017. * | 2 | PLANAR_MODE | |
  30018. * | 3 | CUBIC_MODE | |
  30019. * | 4 | PROJECTION_MODE | |
  30020. * | 5 | SKYBOX_MODE | |
  30021. * | 6 | INVCUBIC_MODE | |
  30022. * | 7 | EQUIRECTANGULAR_MODE | |
  30023. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30024. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30025. */
  30026. set coordinatesMode(value: number);
  30027. get coordinatesMode(): number;
  30028. /**
  30029. * | Value | Type | Description |
  30030. * | ----- | ------------------ | ----------- |
  30031. * | 0 | CLAMP_ADDRESSMODE | |
  30032. * | 1 | WRAP_ADDRESSMODE | |
  30033. * | 2 | MIRROR_ADDRESSMODE | |
  30034. */
  30035. wrapU: number;
  30036. /**
  30037. * | Value | Type | Description |
  30038. * | ----- | ------------------ | ----------- |
  30039. * | 0 | CLAMP_ADDRESSMODE | |
  30040. * | 1 | WRAP_ADDRESSMODE | |
  30041. * | 2 | MIRROR_ADDRESSMODE | |
  30042. */
  30043. wrapV: number;
  30044. /**
  30045. * | Value | Type | Description |
  30046. * | ----- | ------------------ | ----------- |
  30047. * | 0 | CLAMP_ADDRESSMODE | |
  30048. * | 1 | WRAP_ADDRESSMODE | |
  30049. * | 2 | MIRROR_ADDRESSMODE | |
  30050. */
  30051. wrapR: number;
  30052. /**
  30053. * With compliant hardware and browser (supporting anisotropic filtering)
  30054. * this defines the level of anisotropic filtering in the texture.
  30055. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30056. */
  30057. anisotropicFilteringLevel: number;
  30058. /**
  30059. * Define if the texture is a cube texture or if false a 2d texture.
  30060. */
  30061. get isCube(): boolean;
  30062. set isCube(value: boolean);
  30063. /**
  30064. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30065. */
  30066. get is3D(): boolean;
  30067. set is3D(value: boolean);
  30068. /**
  30069. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30070. */
  30071. get is2DArray(): boolean;
  30072. set is2DArray(value: boolean);
  30073. /**
  30074. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30075. * HDR texture are usually stored in linear space.
  30076. * This only impacts the PBR and Background materials
  30077. */
  30078. gammaSpace: boolean;
  30079. /**
  30080. * Gets or sets whether or not the texture contains RGBD data.
  30081. */
  30082. get isRGBD(): boolean;
  30083. set isRGBD(value: boolean);
  30084. /**
  30085. * Is Z inverted in the texture (useful in a cube texture).
  30086. */
  30087. invertZ: boolean;
  30088. /**
  30089. * Are mip maps generated for this texture or not.
  30090. */
  30091. get noMipmap(): boolean;
  30092. /**
  30093. * @hidden
  30094. */
  30095. lodLevelInAlpha: boolean;
  30096. /**
  30097. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30098. */
  30099. get lodGenerationOffset(): number;
  30100. set lodGenerationOffset(value: number);
  30101. /**
  30102. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30103. */
  30104. get lodGenerationScale(): number;
  30105. set lodGenerationScale(value: number);
  30106. /**
  30107. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30108. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30109. * average roughness values.
  30110. */
  30111. get linearSpecularLOD(): boolean;
  30112. set linearSpecularLOD(value: boolean);
  30113. /**
  30114. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30115. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30116. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30117. */
  30118. get irradianceTexture(): Nullable<BaseTexture>;
  30119. set irradianceTexture(value: Nullable<BaseTexture>);
  30120. /**
  30121. * Define if the texture is a render target.
  30122. */
  30123. isRenderTarget: boolean;
  30124. /**
  30125. * Define the unique id of the texture in the scene.
  30126. */
  30127. get uid(): string;
  30128. /**
  30129. * Return a string representation of the texture.
  30130. * @returns the texture as a string
  30131. */
  30132. toString(): string;
  30133. /**
  30134. * Get the class name of the texture.
  30135. * @returns "BaseTexture"
  30136. */
  30137. getClassName(): string;
  30138. /**
  30139. * Define the list of animation attached to the texture.
  30140. */
  30141. animations: Animation[];
  30142. /**
  30143. * An event triggered when the texture is disposed.
  30144. */
  30145. onDisposeObservable: Observable<BaseTexture>;
  30146. private _onDisposeObserver;
  30147. /**
  30148. * Callback triggered when the texture has been disposed.
  30149. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30150. */
  30151. set onDispose(callback: () => void);
  30152. /**
  30153. * Define the current state of the loading sequence when in delayed load mode.
  30154. */
  30155. delayLoadState: number;
  30156. private _scene;
  30157. /** @hidden */
  30158. _texture: Nullable<InternalTexture>;
  30159. private _uid;
  30160. /**
  30161. * Define if the texture is preventinga material to render or not.
  30162. * If not and the texture is not ready, the engine will use a default black texture instead.
  30163. */
  30164. get isBlocking(): boolean;
  30165. /**
  30166. * Instantiates a new BaseTexture.
  30167. * Base class of all the textures in babylon.
  30168. * It groups all the common properties the materials, post process, lights... might need
  30169. * in order to make a correct use of the texture.
  30170. * @param scene Define the scene the texture blongs to
  30171. */
  30172. constructor(scene: Nullable<Scene>);
  30173. /**
  30174. * Get the scene the texture belongs to.
  30175. * @returns the scene or null if undefined
  30176. */
  30177. getScene(): Nullable<Scene>;
  30178. /**
  30179. * Get the texture transform matrix used to offset tile the texture for istance.
  30180. * @returns the transformation matrix
  30181. */
  30182. getTextureMatrix(): Matrix;
  30183. /**
  30184. * Get the texture reflection matrix used to rotate/transform the reflection.
  30185. * @returns the reflection matrix
  30186. */
  30187. getReflectionTextureMatrix(): Matrix;
  30188. /**
  30189. * Get the underlying lower level texture from Babylon.
  30190. * @returns the insternal texture
  30191. */
  30192. getInternalTexture(): Nullable<InternalTexture>;
  30193. /**
  30194. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30195. * @returns true if ready or not blocking
  30196. */
  30197. isReadyOrNotBlocking(): boolean;
  30198. /**
  30199. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30200. * @returns true if fully ready
  30201. */
  30202. isReady(): boolean;
  30203. private _cachedSize;
  30204. /**
  30205. * Get the size of the texture.
  30206. * @returns the texture size.
  30207. */
  30208. getSize(): ISize;
  30209. /**
  30210. * Get the base size of the texture.
  30211. * It can be different from the size if the texture has been resized for POT for instance
  30212. * @returns the base size
  30213. */
  30214. getBaseSize(): ISize;
  30215. /**
  30216. * Update the sampling mode of the texture.
  30217. * Default is Trilinear mode.
  30218. *
  30219. * | Value | Type | Description |
  30220. * | ----- | ------------------ | ----------- |
  30221. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30222. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30223. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30224. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30225. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30226. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30227. * | 7 | NEAREST_LINEAR | |
  30228. * | 8 | NEAREST_NEAREST | |
  30229. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30230. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30231. * | 11 | LINEAR_LINEAR | |
  30232. * | 12 | LINEAR_NEAREST | |
  30233. *
  30234. * > _mag_: magnification filter (close to the viewer)
  30235. * > _min_: minification filter (far from the viewer)
  30236. * > _mip_: filter used between mip map levels
  30237. *@param samplingMode Define the new sampling mode of the texture
  30238. */
  30239. updateSamplingMode(samplingMode: number): void;
  30240. /**
  30241. * Scales the texture if is `canRescale()`
  30242. * @param ratio the resize factor we want to use to rescale
  30243. */
  30244. scale(ratio: number): void;
  30245. /**
  30246. * Get if the texture can rescale.
  30247. */
  30248. get canRescale(): boolean;
  30249. /** @hidden */
  30250. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30251. /** @hidden */
  30252. _rebuild(): void;
  30253. /**
  30254. * Triggers the load sequence in delayed load mode.
  30255. */
  30256. delayLoad(): void;
  30257. /**
  30258. * Clones the texture.
  30259. * @returns the cloned texture
  30260. */
  30261. clone(): Nullable<BaseTexture>;
  30262. /**
  30263. * Get the texture underlying type (INT, FLOAT...)
  30264. */
  30265. get textureType(): number;
  30266. /**
  30267. * Get the texture underlying format (RGB, RGBA...)
  30268. */
  30269. get textureFormat(): number;
  30270. /**
  30271. * Indicates that textures need to be re-calculated for all materials
  30272. */
  30273. protected _markAllSubMeshesAsTexturesDirty(): void;
  30274. /**
  30275. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30276. * This will returns an RGBA array buffer containing either in values (0-255) or
  30277. * float values (0-1) depending of the underlying buffer type.
  30278. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30279. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30280. * @param buffer defines a user defined buffer to fill with data (can be null)
  30281. * @returns The Array buffer containing the pixels data.
  30282. */
  30283. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30284. /**
  30285. * Release and destroy the underlying lower level texture aka internalTexture.
  30286. */
  30287. releaseInternalTexture(): void;
  30288. /** @hidden */
  30289. get _lodTextureHigh(): Nullable<BaseTexture>;
  30290. /** @hidden */
  30291. get _lodTextureMid(): Nullable<BaseTexture>;
  30292. /** @hidden */
  30293. get _lodTextureLow(): Nullable<BaseTexture>;
  30294. /**
  30295. * Dispose the texture and release its associated resources.
  30296. */
  30297. dispose(): void;
  30298. /**
  30299. * Serialize the texture into a JSON representation that can be parsed later on.
  30300. * @returns the JSON representation of the texture
  30301. */
  30302. serialize(): any;
  30303. /**
  30304. * Helper function to be called back once a list of texture contains only ready textures.
  30305. * @param textures Define the list of textures to wait for
  30306. * @param callback Define the callback triggered once the entire list will be ready
  30307. */
  30308. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30309. }
  30310. }
  30311. declare module BABYLON {
  30312. /**
  30313. * Options to be used when creating an effect.
  30314. */
  30315. export interface IEffectCreationOptions {
  30316. /**
  30317. * Atrributes that will be used in the shader.
  30318. */
  30319. attributes: string[];
  30320. /**
  30321. * Uniform varible names that will be set in the shader.
  30322. */
  30323. uniformsNames: string[];
  30324. /**
  30325. * Uniform buffer variable names that will be set in the shader.
  30326. */
  30327. uniformBuffersNames: string[];
  30328. /**
  30329. * Sampler texture variable names that will be set in the shader.
  30330. */
  30331. samplers: string[];
  30332. /**
  30333. * Define statements that will be set in the shader.
  30334. */
  30335. defines: any;
  30336. /**
  30337. * Possible fallbacks for this effect to improve performance when needed.
  30338. */
  30339. fallbacks: Nullable<IEffectFallbacks>;
  30340. /**
  30341. * Callback that will be called when the shader is compiled.
  30342. */
  30343. onCompiled: Nullable<(effect: Effect) => void>;
  30344. /**
  30345. * Callback that will be called if an error occurs during shader compilation.
  30346. */
  30347. onError: Nullable<(effect: Effect, errors: string) => void>;
  30348. /**
  30349. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30350. */
  30351. indexParameters?: any;
  30352. /**
  30353. * Max number of lights that can be used in the shader.
  30354. */
  30355. maxSimultaneousLights?: number;
  30356. /**
  30357. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30358. */
  30359. transformFeedbackVaryings?: Nullable<string[]>;
  30360. }
  30361. /**
  30362. * Effect containing vertex and fragment shader that can be executed on an object.
  30363. */
  30364. export class Effect implements IDisposable {
  30365. /**
  30366. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30367. */
  30368. static ShadersRepository: string;
  30369. /**
  30370. * Enable logging of the shader code when a compilation error occurs
  30371. */
  30372. static LogShaderCodeOnCompilationError: boolean;
  30373. /**
  30374. * Name of the effect.
  30375. */
  30376. name: any;
  30377. /**
  30378. * String container all the define statements that should be set on the shader.
  30379. */
  30380. defines: string;
  30381. /**
  30382. * Callback that will be called when the shader is compiled.
  30383. */
  30384. onCompiled: Nullable<(effect: Effect) => void>;
  30385. /**
  30386. * Callback that will be called if an error occurs during shader compilation.
  30387. */
  30388. onError: Nullable<(effect: Effect, errors: string) => void>;
  30389. /**
  30390. * Callback that will be called when effect is bound.
  30391. */
  30392. onBind: Nullable<(effect: Effect) => void>;
  30393. /**
  30394. * Unique ID of the effect.
  30395. */
  30396. uniqueId: number;
  30397. /**
  30398. * Observable that will be called when the shader is compiled.
  30399. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30400. */
  30401. onCompileObservable: Observable<Effect>;
  30402. /**
  30403. * Observable that will be called if an error occurs during shader compilation.
  30404. */
  30405. onErrorObservable: Observable<Effect>;
  30406. /** @hidden */
  30407. _onBindObservable: Nullable<Observable<Effect>>;
  30408. /**
  30409. * @hidden
  30410. * Specifies if the effect was previously ready
  30411. */
  30412. _wasPreviouslyReady: boolean;
  30413. /**
  30414. * Observable that will be called when effect is bound.
  30415. */
  30416. get onBindObservable(): Observable<Effect>;
  30417. /** @hidden */
  30418. _bonesComputationForcedToCPU: boolean;
  30419. private static _uniqueIdSeed;
  30420. private _engine;
  30421. private _uniformBuffersNames;
  30422. private _uniformsNames;
  30423. private _samplerList;
  30424. private _samplers;
  30425. private _isReady;
  30426. private _compilationError;
  30427. private _allFallbacksProcessed;
  30428. private _attributesNames;
  30429. private _attributes;
  30430. private _attributeLocationByName;
  30431. private _uniforms;
  30432. /**
  30433. * Key for the effect.
  30434. * @hidden
  30435. */
  30436. _key: string;
  30437. private _indexParameters;
  30438. private _fallbacks;
  30439. private _vertexSourceCode;
  30440. private _fragmentSourceCode;
  30441. private _vertexSourceCodeOverride;
  30442. private _fragmentSourceCodeOverride;
  30443. private _transformFeedbackVaryings;
  30444. /**
  30445. * Compiled shader to webGL program.
  30446. * @hidden
  30447. */
  30448. _pipelineContext: Nullable<IPipelineContext>;
  30449. private _valueCache;
  30450. private static _baseCache;
  30451. /**
  30452. * Instantiates an effect.
  30453. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30454. * @param baseName Name of the effect.
  30455. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30456. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30457. * @param samplers List of sampler variables that will be passed to the shader.
  30458. * @param engine Engine to be used to render the effect
  30459. * @param defines Define statements to be added to the shader.
  30460. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30461. * @param onCompiled Callback that will be called when the shader is compiled.
  30462. * @param onError Callback that will be called if an error occurs during shader compilation.
  30463. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30464. */
  30465. 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);
  30466. private _useFinalCode;
  30467. /**
  30468. * Unique key for this effect
  30469. */
  30470. get key(): string;
  30471. /**
  30472. * If the effect has been compiled and prepared.
  30473. * @returns if the effect is compiled and prepared.
  30474. */
  30475. isReady(): boolean;
  30476. private _isReadyInternal;
  30477. /**
  30478. * The engine the effect was initialized with.
  30479. * @returns the engine.
  30480. */
  30481. getEngine(): Engine;
  30482. /**
  30483. * The pipeline context for this effect
  30484. * @returns the associated pipeline context
  30485. */
  30486. getPipelineContext(): Nullable<IPipelineContext>;
  30487. /**
  30488. * The set of names of attribute variables for the shader.
  30489. * @returns An array of attribute names.
  30490. */
  30491. getAttributesNames(): string[];
  30492. /**
  30493. * Returns the attribute at the given index.
  30494. * @param index The index of the attribute.
  30495. * @returns The location of the attribute.
  30496. */
  30497. getAttributeLocation(index: number): number;
  30498. /**
  30499. * Returns the attribute based on the name of the variable.
  30500. * @param name of the attribute to look up.
  30501. * @returns the attribute location.
  30502. */
  30503. getAttributeLocationByName(name: string): number;
  30504. /**
  30505. * The number of attributes.
  30506. * @returns the numnber of attributes.
  30507. */
  30508. getAttributesCount(): number;
  30509. /**
  30510. * Gets the index of a uniform variable.
  30511. * @param uniformName of the uniform to look up.
  30512. * @returns the index.
  30513. */
  30514. getUniformIndex(uniformName: string): number;
  30515. /**
  30516. * Returns the attribute based on the name of the variable.
  30517. * @param uniformName of the uniform to look up.
  30518. * @returns the location of the uniform.
  30519. */
  30520. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30521. /**
  30522. * Returns an array of sampler variable names
  30523. * @returns The array of sampler variable neames.
  30524. */
  30525. getSamplers(): string[];
  30526. /**
  30527. * The error from the last compilation.
  30528. * @returns the error string.
  30529. */
  30530. getCompilationError(): string;
  30531. /**
  30532. * Gets a boolean indicating that all fallbacks were used during compilation
  30533. * @returns true if all fallbacks were used
  30534. */
  30535. allFallbacksProcessed(): boolean;
  30536. /**
  30537. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30538. * @param func The callback to be used.
  30539. */
  30540. executeWhenCompiled(func: (effect: Effect) => void): void;
  30541. private _checkIsReady;
  30542. private _loadShader;
  30543. /**
  30544. * Recompiles the webGL program
  30545. * @param vertexSourceCode The source code for the vertex shader.
  30546. * @param fragmentSourceCode The source code for the fragment shader.
  30547. * @param onCompiled Callback called when completed.
  30548. * @param onError Callback called on error.
  30549. * @hidden
  30550. */
  30551. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30552. /**
  30553. * Prepares the effect
  30554. * @hidden
  30555. */
  30556. _prepareEffect(): void;
  30557. private _getShaderCodeAndErrorLine;
  30558. private _processCompilationErrors;
  30559. /**
  30560. * Checks if the effect is supported. (Must be called after compilation)
  30561. */
  30562. get isSupported(): boolean;
  30563. /**
  30564. * Binds a texture to the engine to be used as output of the shader.
  30565. * @param channel Name of the output variable.
  30566. * @param texture Texture to bind.
  30567. * @hidden
  30568. */
  30569. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30570. /**
  30571. * Sets a texture on the engine to be used in the shader.
  30572. * @param channel Name of the sampler variable.
  30573. * @param texture Texture to set.
  30574. */
  30575. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30576. /**
  30577. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30578. * @param channel Name of the sampler variable.
  30579. * @param texture Texture to set.
  30580. */
  30581. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30582. /**
  30583. * Sets an array of textures on the engine to be used in the shader.
  30584. * @param channel Name of the variable.
  30585. * @param textures Textures to set.
  30586. */
  30587. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30588. /**
  30589. * 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)
  30590. * @param channel Name of the sampler variable.
  30591. * @param postProcess Post process to get the input texture from.
  30592. */
  30593. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30594. /**
  30595. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30596. * 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)
  30597. * @param channel Name of the sampler variable.
  30598. * @param postProcess Post process to get the output texture from.
  30599. */
  30600. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30601. /** @hidden */
  30602. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30603. /** @hidden */
  30604. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30605. /** @hidden */
  30606. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30607. /** @hidden */
  30608. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30609. /**
  30610. * Binds a buffer to a uniform.
  30611. * @param buffer Buffer to bind.
  30612. * @param name Name of the uniform variable to bind to.
  30613. */
  30614. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30615. /**
  30616. * Binds block to a uniform.
  30617. * @param blockName Name of the block to bind.
  30618. * @param index Index to bind.
  30619. */
  30620. bindUniformBlock(blockName: string, index: number): void;
  30621. /**
  30622. * Sets an interger value on a uniform variable.
  30623. * @param uniformName Name of the variable.
  30624. * @param value Value to be set.
  30625. * @returns this effect.
  30626. */
  30627. setInt(uniformName: string, value: number): Effect;
  30628. /**
  30629. * Sets an int array on a uniform variable.
  30630. * @param uniformName Name of the variable.
  30631. * @param array array to be set.
  30632. * @returns this effect.
  30633. */
  30634. setIntArray(uniformName: string, array: Int32Array): Effect;
  30635. /**
  30636. * 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)
  30637. * @param uniformName Name of the variable.
  30638. * @param array array to be set.
  30639. * @returns this effect.
  30640. */
  30641. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30642. /**
  30643. * 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)
  30644. * @param uniformName Name of the variable.
  30645. * @param array array to be set.
  30646. * @returns this effect.
  30647. */
  30648. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30649. /**
  30650. * 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)
  30651. * @param uniformName Name of the variable.
  30652. * @param array array to be set.
  30653. * @returns this effect.
  30654. */
  30655. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30656. /**
  30657. * Sets an float array on a uniform variable.
  30658. * @param uniformName Name of the variable.
  30659. * @param array array to be set.
  30660. * @returns this effect.
  30661. */
  30662. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30663. /**
  30664. * 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)
  30665. * @param uniformName Name of the variable.
  30666. * @param array array to be set.
  30667. * @returns this effect.
  30668. */
  30669. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30670. /**
  30671. * 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)
  30672. * @param uniformName Name of the variable.
  30673. * @param array array to be set.
  30674. * @returns this effect.
  30675. */
  30676. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30677. /**
  30678. * 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)
  30679. * @param uniformName Name of the variable.
  30680. * @param array array to be set.
  30681. * @returns this effect.
  30682. */
  30683. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30684. /**
  30685. * Sets an array on a uniform variable.
  30686. * @param uniformName Name of the variable.
  30687. * @param array array to be set.
  30688. * @returns this effect.
  30689. */
  30690. setArray(uniformName: string, array: number[]): Effect;
  30691. /**
  30692. * 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)
  30693. * @param uniformName Name of the variable.
  30694. * @param array array to be set.
  30695. * @returns this effect.
  30696. */
  30697. setArray2(uniformName: string, array: number[]): Effect;
  30698. /**
  30699. * 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)
  30700. * @param uniformName Name of the variable.
  30701. * @param array array to be set.
  30702. * @returns this effect.
  30703. */
  30704. setArray3(uniformName: string, array: number[]): Effect;
  30705. /**
  30706. * 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)
  30707. * @param uniformName Name of the variable.
  30708. * @param array array to be set.
  30709. * @returns this effect.
  30710. */
  30711. setArray4(uniformName: string, array: number[]): Effect;
  30712. /**
  30713. * Sets matrices on a uniform variable.
  30714. * @param uniformName Name of the variable.
  30715. * @param matrices matrices to be set.
  30716. * @returns this effect.
  30717. */
  30718. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30719. /**
  30720. * Sets matrix on a uniform variable.
  30721. * @param uniformName Name of the variable.
  30722. * @param matrix matrix to be set.
  30723. * @returns this effect.
  30724. */
  30725. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30726. /**
  30727. * 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)
  30728. * @param uniformName Name of the variable.
  30729. * @param matrix matrix to be set.
  30730. * @returns this effect.
  30731. */
  30732. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30733. /**
  30734. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30735. * @param uniformName Name of the variable.
  30736. * @param matrix matrix to be set.
  30737. * @returns this effect.
  30738. */
  30739. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30740. /**
  30741. * Sets a float on a uniform variable.
  30742. * @param uniformName Name of the variable.
  30743. * @param value value to be set.
  30744. * @returns this effect.
  30745. */
  30746. setFloat(uniformName: string, value: number): Effect;
  30747. /**
  30748. * Sets a boolean on a uniform variable.
  30749. * @param uniformName Name of the variable.
  30750. * @param bool value to be set.
  30751. * @returns this effect.
  30752. */
  30753. setBool(uniformName: string, bool: boolean): Effect;
  30754. /**
  30755. * Sets a Vector2 on a uniform variable.
  30756. * @param uniformName Name of the variable.
  30757. * @param vector2 vector2 to be set.
  30758. * @returns this effect.
  30759. */
  30760. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30761. /**
  30762. * Sets a float2 on a uniform variable.
  30763. * @param uniformName Name of the variable.
  30764. * @param x First float in float2.
  30765. * @param y Second float in float2.
  30766. * @returns this effect.
  30767. */
  30768. setFloat2(uniformName: string, x: number, y: number): Effect;
  30769. /**
  30770. * Sets a Vector3 on a uniform variable.
  30771. * @param uniformName Name of the variable.
  30772. * @param vector3 Value to be set.
  30773. * @returns this effect.
  30774. */
  30775. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30776. /**
  30777. * Sets a float3 on a uniform variable.
  30778. * @param uniformName Name of the variable.
  30779. * @param x First float in float3.
  30780. * @param y Second float in float3.
  30781. * @param z Third float in float3.
  30782. * @returns this effect.
  30783. */
  30784. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30785. /**
  30786. * Sets a Vector4 on a uniform variable.
  30787. * @param uniformName Name of the variable.
  30788. * @param vector4 Value to be set.
  30789. * @returns this effect.
  30790. */
  30791. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30792. /**
  30793. * Sets a float4 on a uniform variable.
  30794. * @param uniformName Name of the variable.
  30795. * @param x First float in float4.
  30796. * @param y Second float in float4.
  30797. * @param z Third float in float4.
  30798. * @param w Fourth float in float4.
  30799. * @returns this effect.
  30800. */
  30801. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30802. /**
  30803. * Sets a Color3 on a uniform variable.
  30804. * @param uniformName Name of the variable.
  30805. * @param color3 Value to be set.
  30806. * @returns this effect.
  30807. */
  30808. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30809. /**
  30810. * Sets a Color4 on a uniform variable.
  30811. * @param uniformName Name of the variable.
  30812. * @param color3 Value to be set.
  30813. * @param alpha Alpha value to be set.
  30814. * @returns this effect.
  30815. */
  30816. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30817. /**
  30818. * Sets a Color4 on a uniform variable
  30819. * @param uniformName defines the name of the variable
  30820. * @param color4 defines the value to be set
  30821. * @returns this effect.
  30822. */
  30823. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30824. /** Release all associated resources */
  30825. dispose(): void;
  30826. /**
  30827. * This function will add a new shader to the shader store
  30828. * @param name the name of the shader
  30829. * @param pixelShader optional pixel shader content
  30830. * @param vertexShader optional vertex shader content
  30831. */
  30832. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30833. /**
  30834. * Store of each shader (The can be looked up using effect.key)
  30835. */
  30836. static ShadersStore: {
  30837. [key: string]: string;
  30838. };
  30839. /**
  30840. * Store of each included file for a shader (The can be looked up using effect.key)
  30841. */
  30842. static IncludesShadersStore: {
  30843. [key: string]: string;
  30844. };
  30845. /**
  30846. * Resets the cache of effects.
  30847. */
  30848. static ResetCache(): void;
  30849. }
  30850. }
  30851. declare module BABYLON {
  30852. /**
  30853. * Interface used to describe the capabilities of the engine relatively to the current browser
  30854. */
  30855. export interface EngineCapabilities {
  30856. /** Maximum textures units per fragment shader */
  30857. maxTexturesImageUnits: number;
  30858. /** Maximum texture units per vertex shader */
  30859. maxVertexTextureImageUnits: number;
  30860. /** Maximum textures units in the entire pipeline */
  30861. maxCombinedTexturesImageUnits: number;
  30862. /** Maximum texture size */
  30863. maxTextureSize: number;
  30864. /** Maximum texture samples */
  30865. maxSamples?: number;
  30866. /** Maximum cube texture size */
  30867. maxCubemapTextureSize: number;
  30868. /** Maximum render texture size */
  30869. maxRenderTextureSize: number;
  30870. /** Maximum number of vertex attributes */
  30871. maxVertexAttribs: number;
  30872. /** Maximum number of varyings */
  30873. maxVaryingVectors: number;
  30874. /** Maximum number of uniforms per vertex shader */
  30875. maxVertexUniformVectors: number;
  30876. /** Maximum number of uniforms per fragment shader */
  30877. maxFragmentUniformVectors: number;
  30878. /** Defines if standard derivates (dx/dy) are supported */
  30879. standardDerivatives: boolean;
  30880. /** Defines if s3tc texture compression is supported */
  30881. s3tc?: WEBGL_compressed_texture_s3tc;
  30882. /** Defines if pvrtc texture compression is supported */
  30883. pvrtc: any;
  30884. /** Defines if etc1 texture compression is supported */
  30885. etc1: any;
  30886. /** Defines if etc2 texture compression is supported */
  30887. etc2: any;
  30888. /** Defines if astc texture compression is supported */
  30889. astc: any;
  30890. /** Defines if float textures are supported */
  30891. textureFloat: boolean;
  30892. /** Defines if vertex array objects are supported */
  30893. vertexArrayObject: boolean;
  30894. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30895. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30896. /** Gets the maximum level of anisotropy supported */
  30897. maxAnisotropy: number;
  30898. /** Defines if instancing is supported */
  30899. instancedArrays: boolean;
  30900. /** Defines if 32 bits indices are supported */
  30901. uintIndices: boolean;
  30902. /** Defines if high precision shaders are supported */
  30903. highPrecisionShaderSupported: boolean;
  30904. /** Defines if depth reading in the fragment shader is supported */
  30905. fragmentDepthSupported: boolean;
  30906. /** Defines if float texture linear filtering is supported*/
  30907. textureFloatLinearFiltering: boolean;
  30908. /** Defines if rendering to float textures is supported */
  30909. textureFloatRender: boolean;
  30910. /** Defines if half float textures are supported*/
  30911. textureHalfFloat: boolean;
  30912. /** Defines if half float texture linear filtering is supported*/
  30913. textureHalfFloatLinearFiltering: boolean;
  30914. /** Defines if rendering to half float textures is supported */
  30915. textureHalfFloatRender: boolean;
  30916. /** Defines if textureLOD shader command is supported */
  30917. textureLOD: boolean;
  30918. /** Defines if draw buffers extension is supported */
  30919. drawBuffersExtension: boolean;
  30920. /** Defines if depth textures are supported */
  30921. depthTextureExtension: boolean;
  30922. /** Defines if float color buffer are supported */
  30923. colorBufferFloat: boolean;
  30924. /** Gets disjoint timer query extension (null if not supported) */
  30925. timerQuery?: EXT_disjoint_timer_query;
  30926. /** Defines if timestamp can be used with timer query */
  30927. canUseTimestampForTimerQuery: boolean;
  30928. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30929. multiview?: any;
  30930. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30931. oculusMultiview?: any;
  30932. /** Function used to let the system compiles shaders in background */
  30933. parallelShaderCompile?: {
  30934. COMPLETION_STATUS_KHR: number;
  30935. };
  30936. /** Max number of texture samples for MSAA */
  30937. maxMSAASamples: number;
  30938. /** Defines if the blend min max extension is supported */
  30939. blendMinMax: boolean;
  30940. }
  30941. }
  30942. declare module BABYLON {
  30943. /**
  30944. * @hidden
  30945. **/
  30946. export class DepthCullingState {
  30947. private _isDepthTestDirty;
  30948. private _isDepthMaskDirty;
  30949. private _isDepthFuncDirty;
  30950. private _isCullFaceDirty;
  30951. private _isCullDirty;
  30952. private _isZOffsetDirty;
  30953. private _isFrontFaceDirty;
  30954. private _depthTest;
  30955. private _depthMask;
  30956. private _depthFunc;
  30957. private _cull;
  30958. private _cullFace;
  30959. private _zOffset;
  30960. private _frontFace;
  30961. /**
  30962. * Initializes the state.
  30963. */
  30964. constructor();
  30965. get isDirty(): boolean;
  30966. get zOffset(): number;
  30967. set zOffset(value: number);
  30968. get cullFace(): Nullable<number>;
  30969. set cullFace(value: Nullable<number>);
  30970. get cull(): Nullable<boolean>;
  30971. set cull(value: Nullable<boolean>);
  30972. get depthFunc(): Nullable<number>;
  30973. set depthFunc(value: Nullable<number>);
  30974. get depthMask(): boolean;
  30975. set depthMask(value: boolean);
  30976. get depthTest(): boolean;
  30977. set depthTest(value: boolean);
  30978. get frontFace(): Nullable<number>;
  30979. set frontFace(value: Nullable<number>);
  30980. reset(): void;
  30981. apply(gl: WebGLRenderingContext): void;
  30982. }
  30983. }
  30984. declare module BABYLON {
  30985. /**
  30986. * @hidden
  30987. **/
  30988. export class StencilState {
  30989. /** 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 */
  30990. static readonly ALWAYS: number;
  30991. /** Passed to stencilOperation to specify that stencil value must be kept */
  30992. static readonly KEEP: number;
  30993. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30994. static readonly REPLACE: number;
  30995. private _isStencilTestDirty;
  30996. private _isStencilMaskDirty;
  30997. private _isStencilFuncDirty;
  30998. private _isStencilOpDirty;
  30999. private _stencilTest;
  31000. private _stencilMask;
  31001. private _stencilFunc;
  31002. private _stencilFuncRef;
  31003. private _stencilFuncMask;
  31004. private _stencilOpStencilFail;
  31005. private _stencilOpDepthFail;
  31006. private _stencilOpStencilDepthPass;
  31007. get isDirty(): boolean;
  31008. get stencilFunc(): number;
  31009. set stencilFunc(value: number);
  31010. get stencilFuncRef(): number;
  31011. set stencilFuncRef(value: number);
  31012. get stencilFuncMask(): number;
  31013. set stencilFuncMask(value: number);
  31014. get stencilOpStencilFail(): number;
  31015. set stencilOpStencilFail(value: number);
  31016. get stencilOpDepthFail(): number;
  31017. set stencilOpDepthFail(value: number);
  31018. get stencilOpStencilDepthPass(): number;
  31019. set stencilOpStencilDepthPass(value: number);
  31020. get stencilMask(): number;
  31021. set stencilMask(value: number);
  31022. get stencilTest(): boolean;
  31023. set stencilTest(value: boolean);
  31024. constructor();
  31025. reset(): void;
  31026. apply(gl: WebGLRenderingContext): void;
  31027. }
  31028. }
  31029. declare module BABYLON {
  31030. /**
  31031. * @hidden
  31032. **/
  31033. export class AlphaState {
  31034. private _isAlphaBlendDirty;
  31035. private _isBlendFunctionParametersDirty;
  31036. private _isBlendEquationParametersDirty;
  31037. private _isBlendConstantsDirty;
  31038. private _alphaBlend;
  31039. private _blendFunctionParameters;
  31040. private _blendEquationParameters;
  31041. private _blendConstants;
  31042. /**
  31043. * Initializes the state.
  31044. */
  31045. constructor();
  31046. get isDirty(): boolean;
  31047. get alphaBlend(): boolean;
  31048. set alphaBlend(value: boolean);
  31049. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31050. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31051. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31052. reset(): void;
  31053. apply(gl: WebGLRenderingContext): void;
  31054. }
  31055. }
  31056. declare module BABYLON {
  31057. /** @hidden */
  31058. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31059. attributeProcessor(attribute: string): string;
  31060. varyingProcessor(varying: string, isFragment: boolean): string;
  31061. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31062. }
  31063. }
  31064. declare module BABYLON {
  31065. /**
  31066. * Interface for attribute information associated with buffer instanciation
  31067. */
  31068. export interface InstancingAttributeInfo {
  31069. /**
  31070. * Name of the GLSL attribute
  31071. * if attribute index is not specified, this is used to retrieve the index from the effect
  31072. */
  31073. attributeName: string;
  31074. /**
  31075. * Index/offset of the attribute in the vertex shader
  31076. * if not specified, this will be computes from the name.
  31077. */
  31078. index?: number;
  31079. /**
  31080. * size of the attribute, 1, 2, 3 or 4
  31081. */
  31082. attributeSize: number;
  31083. /**
  31084. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31085. */
  31086. offset: number;
  31087. /**
  31088. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31089. * default to 1
  31090. */
  31091. divisor?: number;
  31092. /**
  31093. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31094. * default is FLOAT
  31095. */
  31096. attributeType?: number;
  31097. /**
  31098. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31099. */
  31100. normalized?: boolean;
  31101. }
  31102. }
  31103. declare module BABYLON {
  31104. interface ThinEngine {
  31105. /**
  31106. * Update a video texture
  31107. * @param texture defines the texture to update
  31108. * @param video defines the video element to use
  31109. * @param invertY defines if data must be stored with Y axis inverted
  31110. */
  31111. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31112. }
  31113. }
  31114. declare module BABYLON {
  31115. /**
  31116. * Settings for finer control over video usage
  31117. */
  31118. export interface VideoTextureSettings {
  31119. /**
  31120. * Applies `autoplay` to video, if specified
  31121. */
  31122. autoPlay?: boolean;
  31123. /**
  31124. * Applies `loop` to video, if specified
  31125. */
  31126. loop?: boolean;
  31127. /**
  31128. * Automatically updates internal texture from video at every frame in the render loop
  31129. */
  31130. autoUpdateTexture: boolean;
  31131. /**
  31132. * Image src displayed during the video loading or until the user interacts with the video.
  31133. */
  31134. poster?: string;
  31135. }
  31136. /**
  31137. * If you want to display a video in your scene, this is the special texture for that.
  31138. * This special texture works similar to other textures, with the exception of a few parameters.
  31139. * @see https://doc.babylonjs.com/how_to/video_texture
  31140. */
  31141. export class VideoTexture extends Texture {
  31142. /**
  31143. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31144. */
  31145. readonly autoUpdateTexture: boolean;
  31146. /**
  31147. * The video instance used by the texture internally
  31148. */
  31149. readonly video: HTMLVideoElement;
  31150. private _onUserActionRequestedObservable;
  31151. /**
  31152. * Event triggerd when a dom action is required by the user to play the video.
  31153. * This happens due to recent changes in browser policies preventing video to auto start.
  31154. */
  31155. get onUserActionRequestedObservable(): Observable<Texture>;
  31156. private _generateMipMaps;
  31157. private _engine;
  31158. private _stillImageCaptured;
  31159. private _displayingPosterTexture;
  31160. private _settings;
  31161. private _createInternalTextureOnEvent;
  31162. private _frameId;
  31163. private _currentSrc;
  31164. /**
  31165. * Creates a video texture.
  31166. * If you want to display a video in your scene, this is the special texture for that.
  31167. * This special texture works similar to other textures, with the exception of a few parameters.
  31168. * @see https://doc.babylonjs.com/how_to/video_texture
  31169. * @param name optional name, will detect from video source, if not defined
  31170. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31171. * @param scene is obviously the current scene.
  31172. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31173. * @param invertY is false by default but can be used to invert video on Y axis
  31174. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31175. * @param settings allows finer control over video usage
  31176. */
  31177. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31178. private _getName;
  31179. private _getVideo;
  31180. private _createInternalTexture;
  31181. private reset;
  31182. /**
  31183. * @hidden Internal method to initiate `update`.
  31184. */
  31185. _rebuild(): void;
  31186. /**
  31187. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31188. */
  31189. update(): void;
  31190. /**
  31191. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31192. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31193. */
  31194. updateTexture(isVisible: boolean): void;
  31195. protected _updateInternalTexture: () => void;
  31196. /**
  31197. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31198. * @param url New url.
  31199. */
  31200. updateURL(url: string): void;
  31201. /**
  31202. * Clones the texture.
  31203. * @returns the cloned texture
  31204. */
  31205. clone(): VideoTexture;
  31206. /**
  31207. * Dispose the texture and release its associated resources.
  31208. */
  31209. dispose(): void;
  31210. /**
  31211. * Creates a video texture straight from a stream.
  31212. * @param scene Define the scene the texture should be created in
  31213. * @param stream Define the stream the texture should be created from
  31214. * @returns The created video texture as a promise
  31215. */
  31216. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31217. /**
  31218. * Creates a video texture straight from your WebCam video feed.
  31219. * @param scene Define the scene the texture should be created in
  31220. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31221. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31222. * @returns The created video texture as a promise
  31223. */
  31224. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31225. minWidth: number;
  31226. maxWidth: number;
  31227. minHeight: number;
  31228. maxHeight: number;
  31229. deviceId: string;
  31230. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31231. /**
  31232. * Creates a video texture straight from your WebCam video feed.
  31233. * @param scene Define the scene the texture should be created in
  31234. * @param onReady Define a callback to triggered once the texture will be ready
  31235. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31236. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31237. */
  31238. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31239. minWidth: number;
  31240. maxWidth: number;
  31241. minHeight: number;
  31242. maxHeight: number;
  31243. deviceId: string;
  31244. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31245. }
  31246. }
  31247. declare module BABYLON {
  31248. /**
  31249. * Defines the interface used by objects working like Scene
  31250. * @hidden
  31251. */
  31252. export interface ISceneLike {
  31253. _addPendingData(data: any): void;
  31254. _removePendingData(data: any): void;
  31255. offlineProvider: IOfflineProvider;
  31256. }
  31257. /** Interface defining initialization parameters for Engine class */
  31258. export interface EngineOptions extends WebGLContextAttributes {
  31259. /**
  31260. * Defines if the engine should no exceed a specified device ratio
  31261. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31262. */
  31263. limitDeviceRatio?: number;
  31264. /**
  31265. * Defines if webvr should be enabled automatically
  31266. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31267. */
  31268. autoEnableWebVR?: boolean;
  31269. /**
  31270. * Defines if webgl2 should be turned off even if supported
  31271. * @see http://doc.babylonjs.com/features/webgl2
  31272. */
  31273. disableWebGL2Support?: boolean;
  31274. /**
  31275. * Defines if webaudio should be initialized as well
  31276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31277. */
  31278. audioEngine?: boolean;
  31279. /**
  31280. * Defines if animations should run using a deterministic lock step
  31281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31282. */
  31283. deterministicLockstep?: boolean;
  31284. /** Defines the maximum steps to use with deterministic lock step mode */
  31285. lockstepMaxSteps?: number;
  31286. /** Defines the seconds between each deterministic lock step */
  31287. timeStep?: number;
  31288. /**
  31289. * Defines that engine should ignore context lost events
  31290. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31291. */
  31292. doNotHandleContextLost?: boolean;
  31293. /**
  31294. * Defines that engine should ignore modifying touch action attribute and style
  31295. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31296. */
  31297. doNotHandleTouchAction?: boolean;
  31298. /**
  31299. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31300. */
  31301. useHighPrecisionFloats?: boolean;
  31302. }
  31303. /**
  31304. * The base engine class (root of all engines)
  31305. */
  31306. export class ThinEngine {
  31307. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31308. static ExceptionList: ({
  31309. key: string;
  31310. capture: string;
  31311. captureConstraint: number;
  31312. targets: string[];
  31313. } | {
  31314. key: string;
  31315. capture: null;
  31316. captureConstraint: null;
  31317. targets: string[];
  31318. })[];
  31319. /** @hidden */
  31320. static _TextureLoaders: IInternalTextureLoader[];
  31321. /**
  31322. * Returns the current npm package of the sdk
  31323. */
  31324. static get NpmPackage(): string;
  31325. /**
  31326. * Returns the current version of the framework
  31327. */
  31328. static get Version(): string;
  31329. /**
  31330. * Returns a string describing the current engine
  31331. */
  31332. get description(): string;
  31333. /**
  31334. * Gets or sets the epsilon value used by collision engine
  31335. */
  31336. static CollisionsEpsilon: number;
  31337. /**
  31338. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31339. */
  31340. static get ShadersRepository(): string;
  31341. static set ShadersRepository(value: string);
  31342. /** @hidden */
  31343. _shaderProcessor: IShaderProcessor;
  31344. /**
  31345. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31346. */
  31347. forcePOTTextures: boolean;
  31348. /**
  31349. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31350. */
  31351. isFullscreen: boolean;
  31352. /**
  31353. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31354. */
  31355. cullBackFaces: boolean;
  31356. /**
  31357. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31358. */
  31359. renderEvenInBackground: boolean;
  31360. /**
  31361. * Gets or sets a boolean indicating that cache can be kept between frames
  31362. */
  31363. preventCacheWipeBetweenFrames: boolean;
  31364. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31365. validateShaderPrograms: boolean;
  31366. /**
  31367. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31368. * This can provide greater z depth for distant objects.
  31369. */
  31370. useReverseDepthBuffer: boolean;
  31371. /**
  31372. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31373. */
  31374. disableUniformBuffers: boolean;
  31375. /** @hidden */
  31376. _uniformBuffers: UniformBuffer[];
  31377. /**
  31378. * Gets a boolean indicating that the engine supports uniform buffers
  31379. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31380. */
  31381. get supportsUniformBuffers(): boolean;
  31382. /** @hidden */
  31383. _gl: WebGLRenderingContext;
  31384. /** @hidden */
  31385. _webGLVersion: number;
  31386. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31387. protected _windowIsBackground: boolean;
  31388. protected _creationOptions: EngineOptions;
  31389. protected _highPrecisionShadersAllowed: boolean;
  31390. /** @hidden */
  31391. get _shouldUseHighPrecisionShader(): boolean;
  31392. /**
  31393. * Gets a boolean indicating that only power of 2 textures are supported
  31394. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31395. */
  31396. get needPOTTextures(): boolean;
  31397. /** @hidden */
  31398. _badOS: boolean;
  31399. /** @hidden */
  31400. _badDesktopOS: boolean;
  31401. private _hardwareScalingLevel;
  31402. /** @hidden */
  31403. _caps: EngineCapabilities;
  31404. private _isStencilEnable;
  31405. private _glVersion;
  31406. private _glRenderer;
  31407. private _glVendor;
  31408. /** @hidden */
  31409. _videoTextureSupported: boolean;
  31410. protected _renderingQueueLaunched: boolean;
  31411. protected _activeRenderLoops: (() => void)[];
  31412. /**
  31413. * Observable signaled when a context lost event is raised
  31414. */
  31415. onContextLostObservable: Observable<ThinEngine>;
  31416. /**
  31417. * Observable signaled when a context restored event is raised
  31418. */
  31419. onContextRestoredObservable: Observable<ThinEngine>;
  31420. private _onContextLost;
  31421. private _onContextRestored;
  31422. protected _contextWasLost: boolean;
  31423. /** @hidden */
  31424. _doNotHandleContextLost: boolean;
  31425. /**
  31426. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31428. */
  31429. get doNotHandleContextLost(): boolean;
  31430. set doNotHandleContextLost(value: boolean);
  31431. /**
  31432. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31433. */
  31434. disableVertexArrayObjects: boolean;
  31435. /** @hidden */
  31436. protected _colorWrite: boolean;
  31437. /** @hidden */
  31438. protected _colorWriteChanged: boolean;
  31439. /** @hidden */
  31440. protected _depthCullingState: DepthCullingState;
  31441. /** @hidden */
  31442. protected _stencilState: StencilState;
  31443. /** @hidden */
  31444. _alphaState: AlphaState;
  31445. /** @hidden */
  31446. _alphaMode: number;
  31447. /** @hidden */
  31448. _alphaEquation: number;
  31449. /** @hidden */
  31450. _internalTexturesCache: InternalTexture[];
  31451. /** @hidden */
  31452. protected _activeChannel: number;
  31453. private _currentTextureChannel;
  31454. /** @hidden */
  31455. protected _boundTexturesCache: {
  31456. [key: string]: Nullable<InternalTexture>;
  31457. };
  31458. /** @hidden */
  31459. protected _currentEffect: Nullable<Effect>;
  31460. /** @hidden */
  31461. protected _currentProgram: Nullable<WebGLProgram>;
  31462. private _compiledEffects;
  31463. private _vertexAttribArraysEnabled;
  31464. /** @hidden */
  31465. protected _cachedViewport: Nullable<IViewportLike>;
  31466. private _cachedVertexArrayObject;
  31467. /** @hidden */
  31468. protected _cachedVertexBuffers: any;
  31469. /** @hidden */
  31470. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31471. /** @hidden */
  31472. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31473. /** @hidden */
  31474. _currentRenderTarget: Nullable<InternalTexture>;
  31475. private _uintIndicesCurrentlySet;
  31476. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31477. /** @hidden */
  31478. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31479. private _currentBufferPointers;
  31480. private _currentInstanceLocations;
  31481. private _currentInstanceBuffers;
  31482. private _textureUnits;
  31483. /** @hidden */
  31484. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31485. /** @hidden */
  31486. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31487. /** @hidden */
  31488. _boundRenderFunction: any;
  31489. private _vaoRecordInProgress;
  31490. private _mustWipeVertexAttributes;
  31491. private _emptyTexture;
  31492. private _emptyCubeTexture;
  31493. private _emptyTexture3D;
  31494. private _emptyTexture2DArray;
  31495. /** @hidden */
  31496. _frameHandler: number;
  31497. private _nextFreeTextureSlots;
  31498. private _maxSimultaneousTextures;
  31499. private _activeRequests;
  31500. /** @hidden */
  31501. _transformTextureUrl: Nullable<(url: string) => string>;
  31502. protected get _supportsHardwareTextureRescaling(): boolean;
  31503. private _framebufferDimensionsObject;
  31504. /**
  31505. * sets the object from which width and height will be taken from when getting render width and height
  31506. * Will fallback to the gl object
  31507. * @param dimensions the framebuffer width and height that will be used.
  31508. */
  31509. set framebufferDimensionsObject(dimensions: Nullable<{
  31510. framebufferWidth: number;
  31511. framebufferHeight: number;
  31512. }>);
  31513. /**
  31514. * Gets the current viewport
  31515. */
  31516. get currentViewport(): Nullable<IViewportLike>;
  31517. /**
  31518. * Gets the default empty texture
  31519. */
  31520. get emptyTexture(): InternalTexture;
  31521. /**
  31522. * Gets the default empty 3D texture
  31523. */
  31524. get emptyTexture3D(): InternalTexture;
  31525. /**
  31526. * Gets the default empty 2D array texture
  31527. */
  31528. get emptyTexture2DArray(): InternalTexture;
  31529. /**
  31530. * Gets the default empty cube texture
  31531. */
  31532. get emptyCubeTexture(): InternalTexture;
  31533. /**
  31534. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31535. */
  31536. readonly premultipliedAlpha: boolean;
  31537. /**
  31538. * Observable event triggered before each texture is initialized
  31539. */
  31540. onBeforeTextureInitObservable: Observable<Texture>;
  31541. /**
  31542. * Creates a new engine
  31543. * @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
  31544. * @param antialias defines enable antialiasing (default: false)
  31545. * @param options defines further options to be sent to the getContext() function
  31546. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31547. */
  31548. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31549. private _rebuildInternalTextures;
  31550. private _rebuildEffects;
  31551. /**
  31552. * Gets a boolean indicating if all created effects are ready
  31553. * @returns true if all effects are ready
  31554. */
  31555. areAllEffectsReady(): boolean;
  31556. protected _rebuildBuffers(): void;
  31557. protected _initGLContext(): void;
  31558. /**
  31559. * Gets version of the current webGL context
  31560. */
  31561. get webGLVersion(): number;
  31562. /**
  31563. * Gets a string idenfifying the name of the class
  31564. * @returns "Engine" string
  31565. */
  31566. getClassName(): string;
  31567. /**
  31568. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31569. */
  31570. get isStencilEnable(): boolean;
  31571. /** @hidden */
  31572. _prepareWorkingCanvas(): void;
  31573. /**
  31574. * Reset the texture cache to empty state
  31575. */
  31576. resetTextureCache(): void;
  31577. /**
  31578. * Gets an object containing information about the current webGL context
  31579. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31580. */
  31581. getGlInfo(): {
  31582. vendor: string;
  31583. renderer: string;
  31584. version: string;
  31585. };
  31586. /**
  31587. * Defines the hardware scaling level.
  31588. * By default the hardware scaling level is computed from the window device ratio.
  31589. * 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.
  31590. * @param level defines the level to use
  31591. */
  31592. setHardwareScalingLevel(level: number): void;
  31593. /**
  31594. * Gets the current hardware scaling level.
  31595. * By default the hardware scaling level is computed from the window device ratio.
  31596. * 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.
  31597. * @returns a number indicating the current hardware scaling level
  31598. */
  31599. getHardwareScalingLevel(): number;
  31600. /**
  31601. * Gets the list of loaded textures
  31602. * @returns an array containing all loaded textures
  31603. */
  31604. getLoadedTexturesCache(): InternalTexture[];
  31605. /**
  31606. * Gets the object containing all engine capabilities
  31607. * @returns the EngineCapabilities object
  31608. */
  31609. getCaps(): EngineCapabilities;
  31610. /**
  31611. * stop executing a render loop function and remove it from the execution array
  31612. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31613. */
  31614. stopRenderLoop(renderFunction?: () => void): void;
  31615. /** @hidden */
  31616. _renderLoop(): void;
  31617. /**
  31618. * Gets the HTML canvas attached with the current webGL context
  31619. * @returns a HTML canvas
  31620. */
  31621. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31622. /**
  31623. * Gets host window
  31624. * @returns the host window object
  31625. */
  31626. getHostWindow(): Nullable<Window>;
  31627. /**
  31628. * Gets the current render width
  31629. * @param useScreen defines if screen size must be used (or the current render target if any)
  31630. * @returns a number defining the current render width
  31631. */
  31632. getRenderWidth(useScreen?: boolean): number;
  31633. /**
  31634. * Gets the current render height
  31635. * @param useScreen defines if screen size must be used (or the current render target if any)
  31636. * @returns a number defining the current render height
  31637. */
  31638. getRenderHeight(useScreen?: boolean): number;
  31639. /**
  31640. * Can be used to override the current requestAnimationFrame requester.
  31641. * @hidden
  31642. */
  31643. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31644. /**
  31645. * Register and execute a render loop. The engine can have more than one render function
  31646. * @param renderFunction defines the function to continuously execute
  31647. */
  31648. runRenderLoop(renderFunction: () => void): void;
  31649. /**
  31650. * Clear the current render buffer or the current render target (if any is set up)
  31651. * @param color defines the color to use
  31652. * @param backBuffer defines if the back buffer must be cleared
  31653. * @param depth defines if the depth buffer must be cleared
  31654. * @param stencil defines if the stencil buffer must be cleared
  31655. */
  31656. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31657. private _viewportCached;
  31658. /** @hidden */
  31659. _viewport(x: number, y: number, width: number, height: number): void;
  31660. /**
  31661. * Set the WebGL's viewport
  31662. * @param viewport defines the viewport element to be used
  31663. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31664. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31665. */
  31666. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31667. /**
  31668. * Begin a new frame
  31669. */
  31670. beginFrame(): void;
  31671. /**
  31672. * Enf the current frame
  31673. */
  31674. endFrame(): void;
  31675. /**
  31676. * Resize the view according to the canvas' size
  31677. */
  31678. resize(): void;
  31679. /**
  31680. * Force a specific size of the canvas
  31681. * @param width defines the new canvas' width
  31682. * @param height defines the new canvas' height
  31683. */
  31684. setSize(width: number, height: number): void;
  31685. /**
  31686. * Binds the frame buffer to the specified texture.
  31687. * @param texture The texture to render to or null for the default canvas
  31688. * @param faceIndex The face of the texture to render to in case of cube texture
  31689. * @param requiredWidth The width of the target to render to
  31690. * @param requiredHeight The height of the target to render to
  31691. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31692. * @param lodLevel defines the lod level to bind to the frame buffer
  31693. * @param layer defines the 2d array index to bind to frame buffer to
  31694. */
  31695. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31696. /** @hidden */
  31697. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31698. /**
  31699. * Unbind the current render target texture from the webGL context
  31700. * @param texture defines the render target texture to unbind
  31701. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31702. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31703. */
  31704. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31705. /**
  31706. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31707. */
  31708. flushFramebuffer(): void;
  31709. /**
  31710. * Unbind the current render target and bind the default framebuffer
  31711. */
  31712. restoreDefaultFramebuffer(): void;
  31713. /** @hidden */
  31714. protected _resetVertexBufferBinding(): void;
  31715. /**
  31716. * Creates a vertex buffer
  31717. * @param data the data for the vertex buffer
  31718. * @returns the new WebGL static buffer
  31719. */
  31720. createVertexBuffer(data: DataArray): DataBuffer;
  31721. private _createVertexBuffer;
  31722. /**
  31723. * Creates a dynamic vertex buffer
  31724. * @param data the data for the dynamic vertex buffer
  31725. * @returns the new WebGL dynamic buffer
  31726. */
  31727. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31728. protected _resetIndexBufferBinding(): void;
  31729. /**
  31730. * Creates a new index buffer
  31731. * @param indices defines the content of the index buffer
  31732. * @param updatable defines if the index buffer must be updatable
  31733. * @returns a new webGL buffer
  31734. */
  31735. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31736. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31737. /**
  31738. * Bind a webGL buffer to the webGL context
  31739. * @param buffer defines the buffer to bind
  31740. */
  31741. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31742. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31743. private bindBuffer;
  31744. /**
  31745. * update the bound buffer with the given data
  31746. * @param data defines the data to update
  31747. */
  31748. updateArrayBuffer(data: Float32Array): void;
  31749. private _vertexAttribPointer;
  31750. /** @hidden */
  31751. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31752. private _bindVertexBuffersAttributes;
  31753. /**
  31754. * Records a vertex array object
  31755. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31756. * @param vertexBuffers defines the list of vertex buffers to store
  31757. * @param indexBuffer defines the index buffer to store
  31758. * @param effect defines the effect to store
  31759. * @returns the new vertex array object
  31760. */
  31761. recordVertexArrayObject(vertexBuffers: {
  31762. [key: string]: VertexBuffer;
  31763. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31764. /**
  31765. * Bind a specific vertex array object
  31766. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31767. * @param vertexArrayObject defines the vertex array object to bind
  31768. * @param indexBuffer defines the index buffer to bind
  31769. */
  31770. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31771. /**
  31772. * Bind webGl buffers directly to the webGL context
  31773. * @param vertexBuffer defines the vertex buffer to bind
  31774. * @param indexBuffer defines the index buffer to bind
  31775. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31776. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31777. * @param effect defines the effect associated with the vertex buffer
  31778. */
  31779. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31780. private _unbindVertexArrayObject;
  31781. /**
  31782. * Bind a list of vertex buffers to the webGL context
  31783. * @param vertexBuffers defines the list of vertex buffers to bind
  31784. * @param indexBuffer defines the index buffer to bind
  31785. * @param effect defines the effect associated with the vertex buffers
  31786. */
  31787. bindBuffers(vertexBuffers: {
  31788. [key: string]: Nullable<VertexBuffer>;
  31789. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31790. /**
  31791. * Unbind all instance attributes
  31792. */
  31793. unbindInstanceAttributes(): void;
  31794. /**
  31795. * Release and free the memory of a vertex array object
  31796. * @param vao defines the vertex array object to delete
  31797. */
  31798. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31799. /** @hidden */
  31800. _releaseBuffer(buffer: DataBuffer): boolean;
  31801. protected _deleteBuffer(buffer: DataBuffer): void;
  31802. /**
  31803. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31804. * @param instancesBuffer defines the webGL buffer to update and bind
  31805. * @param data defines the data to store in the buffer
  31806. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31807. */
  31808. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31809. /**
  31810. * Bind the content of a webGL buffer used with instantiation
  31811. * @param instancesBuffer defines the webGL buffer to bind
  31812. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31813. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31814. */
  31815. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31816. /**
  31817. * Disable the instance attribute corresponding to the name in parameter
  31818. * @param name defines the name of the attribute to disable
  31819. */
  31820. disableInstanceAttributeByName(name: string): void;
  31821. /**
  31822. * Disable the instance attribute corresponding to the location in parameter
  31823. * @param attributeLocation defines the attribute location of the attribute to disable
  31824. */
  31825. disableInstanceAttribute(attributeLocation: number): void;
  31826. /**
  31827. * Disable the attribute corresponding to the location in parameter
  31828. * @param attributeLocation defines the attribute location of the attribute to disable
  31829. */
  31830. disableAttributeByIndex(attributeLocation: number): void;
  31831. /**
  31832. * Send a draw order
  31833. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31834. * @param indexStart defines the starting index
  31835. * @param indexCount defines the number of index to draw
  31836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31837. */
  31838. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31839. /**
  31840. * Draw a list of points
  31841. * @param verticesStart defines the index of first vertex to draw
  31842. * @param verticesCount defines the count of vertices to draw
  31843. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31844. */
  31845. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31846. /**
  31847. * Draw a list of unindexed primitives
  31848. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31849. * @param verticesStart defines the index of first vertex to draw
  31850. * @param verticesCount defines the count of vertices to draw
  31851. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31852. */
  31853. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31854. /**
  31855. * Draw a list of indexed primitives
  31856. * @param fillMode defines the primitive to use
  31857. * @param indexStart defines the starting index
  31858. * @param indexCount defines the number of index to draw
  31859. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31860. */
  31861. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31862. /**
  31863. * Draw a list of unindexed primitives
  31864. * @param fillMode defines the primitive to use
  31865. * @param verticesStart defines the index of first vertex to draw
  31866. * @param verticesCount defines the count of vertices to draw
  31867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31868. */
  31869. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31870. private _drawMode;
  31871. /** @hidden */
  31872. protected _reportDrawCall(): void;
  31873. /** @hidden */
  31874. _releaseEffect(effect: Effect): void;
  31875. /** @hidden */
  31876. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31877. /**
  31878. * Create a new effect (used to store vertex/fragment shaders)
  31879. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31880. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31881. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31882. * @param samplers defines an array of string used to represent textures
  31883. * @param defines defines the string containing the defines to use to compile the shaders
  31884. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31885. * @param onCompiled defines a function to call when the effect creation is successful
  31886. * @param onError defines a function to call when the effect creation has failed
  31887. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31888. * @returns the new Effect
  31889. */
  31890. 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;
  31891. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31892. private _compileShader;
  31893. private _compileRawShader;
  31894. /** @hidden */
  31895. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31896. /**
  31897. * Directly creates a webGL program
  31898. * @param pipelineContext defines the pipeline context to attach to
  31899. * @param vertexCode defines the vertex shader code to use
  31900. * @param fragmentCode defines the fragment shader code to use
  31901. * @param context defines the webGL context to use (if not set, the current one will be used)
  31902. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31903. * @returns the new webGL program
  31904. */
  31905. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31906. /**
  31907. * Creates a webGL program
  31908. * @param pipelineContext defines the pipeline context to attach to
  31909. * @param vertexCode defines the vertex shader code to use
  31910. * @param fragmentCode defines the fragment shader code to use
  31911. * @param defines defines the string containing the defines to use to compile the shaders
  31912. * @param context defines the webGL context to use (if not set, the current one will be used)
  31913. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31914. * @returns the new webGL program
  31915. */
  31916. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31917. /**
  31918. * Creates a new pipeline context
  31919. * @returns the new pipeline
  31920. */
  31921. createPipelineContext(): IPipelineContext;
  31922. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31923. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31924. /** @hidden */
  31925. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31926. /** @hidden */
  31927. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31928. /** @hidden */
  31929. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31930. /**
  31931. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31932. * @param pipelineContext defines the pipeline context to use
  31933. * @param uniformsNames defines the list of uniform names
  31934. * @returns an array of webGL uniform locations
  31935. */
  31936. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31937. /**
  31938. * Gets the lsit of active attributes for a given webGL program
  31939. * @param pipelineContext defines the pipeline context to use
  31940. * @param attributesNames defines the list of attribute names to get
  31941. * @returns an array of indices indicating the offset of each attribute
  31942. */
  31943. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31944. /**
  31945. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31946. * @param effect defines the effect to activate
  31947. */
  31948. enableEffect(effect: Nullable<Effect>): void;
  31949. /**
  31950. * Set the value of an uniform to a number (int)
  31951. * @param uniform defines the webGL uniform location where to store the value
  31952. * @param value defines the int number to store
  31953. */
  31954. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31955. /**
  31956. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31961. /**
  31962. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31967. /**
  31968. * Set the value of an uniform to an array of int32 (stored as vec3)
  31969. * @param uniform defines the webGL uniform location where to store the value
  31970. * @param array defines the array of int32 to store
  31971. */
  31972. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31973. /**
  31974. * Set the value of an uniform to an array of int32 (stored as vec4)
  31975. * @param uniform defines the webGL uniform location where to store the value
  31976. * @param array defines the array of int32 to store
  31977. */
  31978. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31979. /**
  31980. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31985. /**
  31986. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31991. /**
  31992. * Set the value of an uniform to an array of number (stored as vec3)
  31993. * @param uniform defines the webGL uniform location where to store the value
  31994. * @param array defines the array of number to store
  31995. */
  31996. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31997. /**
  31998. * Set the value of an uniform to an array of number (stored as vec4)
  31999. * @param uniform defines the webGL uniform location where to store the value
  32000. * @param array defines the array of number to store
  32001. */
  32002. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32003. /**
  32004. * Set the value of an uniform to an array of float32 (stored as matrices)
  32005. * @param uniform defines the webGL uniform location where to store the value
  32006. * @param matrices defines the array of float32 to store
  32007. */
  32008. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32009. /**
  32010. * Set the value of an uniform to a matrix (3x3)
  32011. * @param uniform defines the webGL uniform location where to store the value
  32012. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32013. */
  32014. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32015. /**
  32016. * Set the value of an uniform to a matrix (2x2)
  32017. * @param uniform defines the webGL uniform location where to store the value
  32018. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32019. */
  32020. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32021. /**
  32022. * Set the value of an uniform to a number (float)
  32023. * @param uniform defines the webGL uniform location where to store the value
  32024. * @param value defines the float number to store
  32025. */
  32026. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32027. /**
  32028. * Set the value of an uniform to a vec2
  32029. * @param uniform defines the webGL uniform location where to store the value
  32030. * @param x defines the 1st component of the value
  32031. * @param y defines the 2nd component of the value
  32032. */
  32033. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32034. /**
  32035. * Set the value of an uniform to a vec3
  32036. * @param uniform defines the webGL uniform location where to store the value
  32037. * @param x defines the 1st component of the value
  32038. * @param y defines the 2nd component of the value
  32039. * @param z defines the 3rd component of the value
  32040. */
  32041. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32042. /**
  32043. * Set the value of an uniform to a vec4
  32044. * @param uniform defines the webGL uniform location where to store the value
  32045. * @param x defines the 1st component of the value
  32046. * @param y defines the 2nd component of the value
  32047. * @param z defines the 3rd component of the value
  32048. * @param w defines the 4th component of the value
  32049. */
  32050. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32051. /**
  32052. * Apply all cached states (depth, culling, stencil and alpha)
  32053. */
  32054. applyStates(): void;
  32055. /**
  32056. * Enable or disable color writing
  32057. * @param enable defines the state to set
  32058. */
  32059. setColorWrite(enable: boolean): void;
  32060. /**
  32061. * Gets a boolean indicating if color writing is enabled
  32062. * @returns the current color writing state
  32063. */
  32064. getColorWrite(): boolean;
  32065. /**
  32066. * Gets the depth culling state manager
  32067. */
  32068. get depthCullingState(): DepthCullingState;
  32069. /**
  32070. * Gets the alpha state manager
  32071. */
  32072. get alphaState(): AlphaState;
  32073. /**
  32074. * Gets the stencil state manager
  32075. */
  32076. get stencilState(): StencilState;
  32077. /**
  32078. * Clears the list of texture accessible through engine.
  32079. * This can help preventing texture load conflict due to name collision.
  32080. */
  32081. clearInternalTexturesCache(): void;
  32082. /**
  32083. * Force the entire cache to be cleared
  32084. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32085. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32086. */
  32087. wipeCaches(bruteForce?: boolean): void;
  32088. /** @hidden */
  32089. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32090. min: number;
  32091. mag: number;
  32092. };
  32093. /** @hidden */
  32094. _createTexture(): WebGLTexture;
  32095. /**
  32096. * Usually called from Texture.ts.
  32097. * Passed information to create a WebGLTexture
  32098. * @param url defines a value which contains one of the following:
  32099. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32100. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32101. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32102. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32103. * @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)
  32104. * @param scene needed for loading to the correct scene
  32105. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32106. * @param onLoad optional callback to be called upon successful completion
  32107. * @param onError optional callback to be called upon failure
  32108. * @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
  32109. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32110. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32111. * @param forcedExtension defines the extension to use to pick the right loader
  32112. * @param mimeType defines an optional mime type
  32113. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32114. */
  32115. 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;
  32116. /**
  32117. * Loads an image as an HTMLImageElement.
  32118. * @param input url string, ArrayBuffer, or Blob to load
  32119. * @param onLoad callback called when the image successfully loads
  32120. * @param onError callback called when the image fails to load
  32121. * @param offlineProvider offline provider for caching
  32122. * @param mimeType optional mime type
  32123. * @returns the HTMLImageElement of the loaded image
  32124. * @hidden
  32125. */
  32126. 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>;
  32127. /**
  32128. * @hidden
  32129. */
  32130. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32131. /**
  32132. * Creates a raw texture
  32133. * @param data defines the data to store in the texture
  32134. * @param width defines the width of the texture
  32135. * @param height defines the height of the texture
  32136. * @param format defines the format of the data
  32137. * @param generateMipMaps defines if the engine should generate the mip levels
  32138. * @param invertY defines if data must be stored with Y axis inverted
  32139. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32140. * @param compression defines the compression used (null by default)
  32141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32142. * @returns the raw texture inside an InternalTexture
  32143. */
  32144. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32145. /**
  32146. * Creates a new raw cube texture
  32147. * @param data defines the array of data to use to create each face
  32148. * @param size defines the size of the textures
  32149. * @param format defines the format of the data
  32150. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32151. * @param generateMipMaps defines if the engine should generate the mip levels
  32152. * @param invertY defines if data must be stored with Y axis inverted
  32153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32154. * @param compression defines the compression used (null by default)
  32155. * @returns the cube texture as an InternalTexture
  32156. */
  32157. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32158. /**
  32159. * Creates a new raw 3D texture
  32160. * @param data defines the data used to create the texture
  32161. * @param width defines the width of the texture
  32162. * @param height defines the height of the texture
  32163. * @param depth defines the depth of the texture
  32164. * @param format defines the format of the texture
  32165. * @param generateMipMaps defines if the engine must generate mip levels
  32166. * @param invertY defines if data must be stored with Y axis inverted
  32167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32168. * @param compression defines the compressed used (can be null)
  32169. * @param textureType defines the compressed used (can be null)
  32170. * @returns a new raw 3D texture (stored in an InternalTexture)
  32171. */
  32172. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32173. /**
  32174. * Creates a new raw 2D array texture
  32175. * @param data defines the data used to create the texture
  32176. * @param width defines the width of the texture
  32177. * @param height defines the height of the texture
  32178. * @param depth defines the number of layers of the texture
  32179. * @param format defines the format of the texture
  32180. * @param generateMipMaps defines if the engine must generate mip levels
  32181. * @param invertY defines if data must be stored with Y axis inverted
  32182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32183. * @param compression defines the compressed used (can be null)
  32184. * @param textureType defines the compressed used (can be null)
  32185. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32186. */
  32187. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32188. private _unpackFlipYCached;
  32189. /**
  32190. * In case you are sharing the context with other applications, it might
  32191. * be interested to not cache the unpack flip y state to ensure a consistent
  32192. * value would be set.
  32193. */
  32194. enableUnpackFlipYCached: boolean;
  32195. /** @hidden */
  32196. _unpackFlipY(value: boolean): void;
  32197. /** @hidden */
  32198. _getUnpackAlignement(): number;
  32199. private _getTextureTarget;
  32200. /**
  32201. * Update the sampling mode of a given texture
  32202. * @param samplingMode defines the required sampling mode
  32203. * @param texture defines the texture to update
  32204. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32205. */
  32206. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32207. /**
  32208. * Update the sampling mode of a given texture
  32209. * @param texture defines the texture to update
  32210. * @param wrapU defines the texture wrap mode of the u coordinates
  32211. * @param wrapV defines the texture wrap mode of the v coordinates
  32212. * @param wrapR defines the texture wrap mode of the r coordinates
  32213. */
  32214. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32215. /** @hidden */
  32216. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32217. width: number;
  32218. height: number;
  32219. layers?: number;
  32220. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32221. /** @hidden */
  32222. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32223. /** @hidden */
  32224. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32225. /**
  32226. * Update a portion of an internal texture
  32227. * @param texture defines the texture to update
  32228. * @param imageData defines the data to store into the texture
  32229. * @param xOffset defines the x coordinates of the update rectangle
  32230. * @param yOffset defines the y coordinates of the update rectangle
  32231. * @param width defines the width of the update rectangle
  32232. * @param height defines the height of the update rectangle
  32233. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32234. * @param lod defines the lod level to update (0 by default)
  32235. */
  32236. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32237. /** @hidden */
  32238. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32239. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32240. private _prepareWebGLTexture;
  32241. /** @hidden */
  32242. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32243. private _getDepthStencilBuffer;
  32244. /** @hidden */
  32245. _releaseFramebufferObjects(texture: InternalTexture): void;
  32246. /** @hidden */
  32247. _releaseTexture(texture: InternalTexture): void;
  32248. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32249. protected _setProgram(program: WebGLProgram): void;
  32250. protected _boundUniforms: {
  32251. [key: number]: WebGLUniformLocation;
  32252. };
  32253. /**
  32254. * Binds an effect to the webGL context
  32255. * @param effect defines the effect to bind
  32256. */
  32257. bindSamplers(effect: Effect): void;
  32258. private _activateCurrentTexture;
  32259. /** @hidden */
  32260. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32261. /** @hidden */
  32262. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32263. /**
  32264. * Unbind all textures from the webGL context
  32265. */
  32266. unbindAllTextures(): void;
  32267. /**
  32268. * Sets a texture to the according uniform.
  32269. * @param channel The texture channel
  32270. * @param uniform The uniform to set
  32271. * @param texture The texture to apply
  32272. */
  32273. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32274. private _bindSamplerUniformToChannel;
  32275. private _getTextureWrapMode;
  32276. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32277. /**
  32278. * Sets an array of texture to the webGL context
  32279. * @param channel defines the channel where the texture array must be set
  32280. * @param uniform defines the associated uniform location
  32281. * @param textures defines the array of textures to bind
  32282. */
  32283. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32284. /** @hidden */
  32285. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32286. private _setTextureParameterFloat;
  32287. private _setTextureParameterInteger;
  32288. /**
  32289. * Unbind all vertex attributes from the webGL context
  32290. */
  32291. unbindAllAttributes(): void;
  32292. /**
  32293. * 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
  32294. */
  32295. releaseEffects(): void;
  32296. /**
  32297. * Dispose and release all associated resources
  32298. */
  32299. dispose(): void;
  32300. /**
  32301. * Attach a new callback raised when context lost event is fired
  32302. * @param callback defines the callback to call
  32303. */
  32304. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32305. /**
  32306. * Attach a new callback raised when context restored event is fired
  32307. * @param callback defines the callback to call
  32308. */
  32309. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32310. /**
  32311. * Get the current error code of the webGL context
  32312. * @returns the error code
  32313. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32314. */
  32315. getError(): number;
  32316. private _canRenderToFloatFramebuffer;
  32317. private _canRenderToHalfFloatFramebuffer;
  32318. private _canRenderToFramebuffer;
  32319. /** @hidden */
  32320. _getWebGLTextureType(type: number): number;
  32321. /** @hidden */
  32322. _getInternalFormat(format: number): number;
  32323. /** @hidden */
  32324. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32325. /** @hidden */
  32326. _getRGBAMultiSampleBufferFormat(type: number): number;
  32327. /** @hidden */
  32328. _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;
  32329. /**
  32330. * Loads a file from a url
  32331. * @param url url to load
  32332. * @param onSuccess callback called when the file successfully loads
  32333. * @param onProgress callback called while file is loading (if the server supports this mode)
  32334. * @param offlineProvider defines the offline provider for caching
  32335. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32336. * @param onError callback called when the file fails to load
  32337. * @returns a file request object
  32338. * @hidden
  32339. */
  32340. 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;
  32341. /**
  32342. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32343. * @param x defines the x coordinate of the rectangle where pixels must be read
  32344. * @param y defines the y coordinate of the rectangle where pixels must be read
  32345. * @param width defines the width of the rectangle where pixels must be read
  32346. * @param height defines the height of the rectangle where pixels must be read
  32347. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32348. * @returns a Uint8Array containing RGBA colors
  32349. */
  32350. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32351. private static _isSupported;
  32352. /**
  32353. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32354. * @returns true if the engine can be created
  32355. * @ignorenaming
  32356. */
  32357. static isSupported(): boolean;
  32358. /**
  32359. * Find the next highest power of two.
  32360. * @param x Number to start search from.
  32361. * @return Next highest power of two.
  32362. */
  32363. static CeilingPOT(x: number): number;
  32364. /**
  32365. * Find the next lowest power of two.
  32366. * @param x Number to start search from.
  32367. * @return Next lowest power of two.
  32368. */
  32369. static FloorPOT(x: number): number;
  32370. /**
  32371. * Find the nearest power of two.
  32372. * @param x Number to start search from.
  32373. * @return Next nearest power of two.
  32374. */
  32375. static NearestPOT(x: number): number;
  32376. /**
  32377. * Get the closest exponent of two
  32378. * @param value defines the value to approximate
  32379. * @param max defines the maximum value to return
  32380. * @param mode defines how to define the closest value
  32381. * @returns closest exponent of two of the given value
  32382. */
  32383. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32384. /**
  32385. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32386. * @param func - the function to be called
  32387. * @param requester - the object that will request the next frame. Falls back to window.
  32388. * @returns frame number
  32389. */
  32390. static QueueNewFrame(func: () => void, requester?: any): number;
  32391. /**
  32392. * Gets host document
  32393. * @returns the host document object
  32394. */
  32395. getHostDocument(): Nullable<Document>;
  32396. }
  32397. }
  32398. declare module BABYLON {
  32399. /**
  32400. * Class representing spherical harmonics coefficients to the 3rd degree
  32401. */
  32402. export class SphericalHarmonics {
  32403. /**
  32404. * Defines whether or not the harmonics have been prescaled for rendering.
  32405. */
  32406. preScaled: boolean;
  32407. /**
  32408. * The l0,0 coefficients of the spherical harmonics
  32409. */
  32410. l00: Vector3;
  32411. /**
  32412. * The l1,-1 coefficients of the spherical harmonics
  32413. */
  32414. l1_1: Vector3;
  32415. /**
  32416. * The l1,0 coefficients of the spherical harmonics
  32417. */
  32418. l10: Vector3;
  32419. /**
  32420. * The l1,1 coefficients of the spherical harmonics
  32421. */
  32422. l11: Vector3;
  32423. /**
  32424. * The l2,-2 coefficients of the spherical harmonics
  32425. */
  32426. l2_2: Vector3;
  32427. /**
  32428. * The l2,-1 coefficients of the spherical harmonics
  32429. */
  32430. l2_1: Vector3;
  32431. /**
  32432. * The l2,0 coefficients of the spherical harmonics
  32433. */
  32434. l20: Vector3;
  32435. /**
  32436. * The l2,1 coefficients of the spherical harmonics
  32437. */
  32438. l21: Vector3;
  32439. /**
  32440. * The l2,2 coefficients of the spherical harmonics
  32441. */
  32442. l22: Vector3;
  32443. /**
  32444. * Adds a light to the spherical harmonics
  32445. * @param direction the direction of the light
  32446. * @param color the color of the light
  32447. * @param deltaSolidAngle the delta solid angle of the light
  32448. */
  32449. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32450. /**
  32451. * Scales the spherical harmonics by the given amount
  32452. * @param scale the amount to scale
  32453. */
  32454. scaleInPlace(scale: number): void;
  32455. /**
  32456. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32457. *
  32458. * ```
  32459. * E_lm = A_l * L_lm
  32460. * ```
  32461. *
  32462. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32463. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32464. * the scaling factors are given in equation 9.
  32465. */
  32466. convertIncidentRadianceToIrradiance(): void;
  32467. /**
  32468. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32469. *
  32470. * ```
  32471. * L = (1/pi) * E * rho
  32472. * ```
  32473. *
  32474. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32475. */
  32476. convertIrradianceToLambertianRadiance(): void;
  32477. /**
  32478. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32479. * required operations at run time.
  32480. *
  32481. * This is simply done by scaling back the SH with Ylm constants parameter.
  32482. * The trigonometric part being applied by the shader at run time.
  32483. */
  32484. preScaleForRendering(): void;
  32485. /**
  32486. * Constructs a spherical harmonics from an array.
  32487. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32488. * @returns the spherical harmonics
  32489. */
  32490. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32491. /**
  32492. * Gets the spherical harmonics from polynomial
  32493. * @param polynomial the spherical polynomial
  32494. * @returns the spherical harmonics
  32495. */
  32496. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32497. }
  32498. /**
  32499. * Class representing spherical polynomial coefficients to the 3rd degree
  32500. */
  32501. export class SphericalPolynomial {
  32502. private _harmonics;
  32503. /**
  32504. * The spherical harmonics used to create the polynomials.
  32505. */
  32506. get preScaledHarmonics(): SphericalHarmonics;
  32507. /**
  32508. * The x coefficients of the spherical polynomial
  32509. */
  32510. x: Vector3;
  32511. /**
  32512. * The y coefficients of the spherical polynomial
  32513. */
  32514. y: Vector3;
  32515. /**
  32516. * The z coefficients of the spherical polynomial
  32517. */
  32518. z: Vector3;
  32519. /**
  32520. * The xx coefficients of the spherical polynomial
  32521. */
  32522. xx: Vector3;
  32523. /**
  32524. * The yy coefficients of the spherical polynomial
  32525. */
  32526. yy: Vector3;
  32527. /**
  32528. * The zz coefficients of the spherical polynomial
  32529. */
  32530. zz: Vector3;
  32531. /**
  32532. * The xy coefficients of the spherical polynomial
  32533. */
  32534. xy: Vector3;
  32535. /**
  32536. * The yz coefficients of the spherical polynomial
  32537. */
  32538. yz: Vector3;
  32539. /**
  32540. * The zx coefficients of the spherical polynomial
  32541. */
  32542. zx: Vector3;
  32543. /**
  32544. * Adds an ambient color to the spherical polynomial
  32545. * @param color the color to add
  32546. */
  32547. addAmbient(color: Color3): void;
  32548. /**
  32549. * Scales the spherical polynomial by the given amount
  32550. * @param scale the amount to scale
  32551. */
  32552. scaleInPlace(scale: number): void;
  32553. /**
  32554. * Gets the spherical polynomial from harmonics
  32555. * @param harmonics the spherical harmonics
  32556. * @returns the spherical polynomial
  32557. */
  32558. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32559. /**
  32560. * Constructs a spherical polynomial from an array.
  32561. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32562. * @returns the spherical polynomial
  32563. */
  32564. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32565. }
  32566. }
  32567. declare module BABYLON {
  32568. /**
  32569. * Defines the source of the internal texture
  32570. */
  32571. export enum InternalTextureSource {
  32572. /**
  32573. * The source of the texture data is unknown
  32574. */
  32575. Unknown = 0,
  32576. /**
  32577. * Texture data comes from an URL
  32578. */
  32579. Url = 1,
  32580. /**
  32581. * Texture data is only used for temporary storage
  32582. */
  32583. Temp = 2,
  32584. /**
  32585. * Texture data comes from raw data (ArrayBuffer)
  32586. */
  32587. Raw = 3,
  32588. /**
  32589. * Texture content is dynamic (video or dynamic texture)
  32590. */
  32591. Dynamic = 4,
  32592. /**
  32593. * Texture content is generated by rendering to it
  32594. */
  32595. RenderTarget = 5,
  32596. /**
  32597. * Texture content is part of a multi render target process
  32598. */
  32599. MultiRenderTarget = 6,
  32600. /**
  32601. * Texture data comes from a cube data file
  32602. */
  32603. Cube = 7,
  32604. /**
  32605. * Texture data comes from a raw cube data
  32606. */
  32607. CubeRaw = 8,
  32608. /**
  32609. * Texture data come from a prefiltered cube data file
  32610. */
  32611. CubePrefiltered = 9,
  32612. /**
  32613. * Texture content is raw 3D data
  32614. */
  32615. Raw3D = 10,
  32616. /**
  32617. * Texture content is raw 2D array data
  32618. */
  32619. Raw2DArray = 11,
  32620. /**
  32621. * Texture content is a depth texture
  32622. */
  32623. Depth = 12,
  32624. /**
  32625. * Texture data comes from a raw cube data encoded with RGBD
  32626. */
  32627. CubeRawRGBD = 13
  32628. }
  32629. /**
  32630. * Class used to store data associated with WebGL texture data for the engine
  32631. * This class should not be used directly
  32632. */
  32633. export class InternalTexture {
  32634. /** @hidden */
  32635. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32636. /**
  32637. * Defines if the texture is ready
  32638. */
  32639. isReady: boolean;
  32640. /**
  32641. * Defines if the texture is a cube texture
  32642. */
  32643. isCube: boolean;
  32644. /**
  32645. * Defines if the texture contains 3D data
  32646. */
  32647. is3D: boolean;
  32648. /**
  32649. * Defines if the texture contains 2D array data
  32650. */
  32651. is2DArray: boolean;
  32652. /**
  32653. * Defines if the texture contains multiview data
  32654. */
  32655. isMultiview: boolean;
  32656. /**
  32657. * Gets the URL used to load this texture
  32658. */
  32659. url: string;
  32660. /**
  32661. * Gets the sampling mode of the texture
  32662. */
  32663. samplingMode: number;
  32664. /**
  32665. * Gets a boolean indicating if the texture needs mipmaps generation
  32666. */
  32667. generateMipMaps: boolean;
  32668. /**
  32669. * Gets the number of samples used by the texture (WebGL2+ only)
  32670. */
  32671. samples: number;
  32672. /**
  32673. * Gets the type of the texture (int, float...)
  32674. */
  32675. type: number;
  32676. /**
  32677. * Gets the format of the texture (RGB, RGBA...)
  32678. */
  32679. format: number;
  32680. /**
  32681. * Observable called when the texture is loaded
  32682. */
  32683. onLoadedObservable: Observable<InternalTexture>;
  32684. /**
  32685. * Gets the width of the texture
  32686. */
  32687. width: number;
  32688. /**
  32689. * Gets the height of the texture
  32690. */
  32691. height: number;
  32692. /**
  32693. * Gets the depth of the texture
  32694. */
  32695. depth: number;
  32696. /**
  32697. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32698. */
  32699. baseWidth: number;
  32700. /**
  32701. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32702. */
  32703. baseHeight: number;
  32704. /**
  32705. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32706. */
  32707. baseDepth: number;
  32708. /**
  32709. * Gets a boolean indicating if the texture is inverted on Y axis
  32710. */
  32711. invertY: boolean;
  32712. /** @hidden */
  32713. _invertVScale: boolean;
  32714. /** @hidden */
  32715. _associatedChannel: number;
  32716. /** @hidden */
  32717. _source: InternalTextureSource;
  32718. /** @hidden */
  32719. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32720. /** @hidden */
  32721. _bufferView: Nullable<ArrayBufferView>;
  32722. /** @hidden */
  32723. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32724. /** @hidden */
  32725. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32726. /** @hidden */
  32727. _size: number;
  32728. /** @hidden */
  32729. _extension: string;
  32730. /** @hidden */
  32731. _files: Nullable<string[]>;
  32732. /** @hidden */
  32733. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32734. /** @hidden */
  32735. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32736. /** @hidden */
  32737. _framebuffer: Nullable<WebGLFramebuffer>;
  32738. /** @hidden */
  32739. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32740. /** @hidden */
  32741. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32742. /** @hidden */
  32743. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32744. /** @hidden */
  32745. _attachments: Nullable<number[]>;
  32746. /** @hidden */
  32747. _cachedCoordinatesMode: Nullable<number>;
  32748. /** @hidden */
  32749. _cachedWrapU: Nullable<number>;
  32750. /** @hidden */
  32751. _cachedWrapV: Nullable<number>;
  32752. /** @hidden */
  32753. _cachedWrapR: Nullable<number>;
  32754. /** @hidden */
  32755. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32756. /** @hidden */
  32757. _isDisabled: boolean;
  32758. /** @hidden */
  32759. _compression: Nullable<string>;
  32760. /** @hidden */
  32761. _generateStencilBuffer: boolean;
  32762. /** @hidden */
  32763. _generateDepthBuffer: boolean;
  32764. /** @hidden */
  32765. _comparisonFunction: number;
  32766. /** @hidden */
  32767. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32768. /** @hidden */
  32769. _lodGenerationScale: number;
  32770. /** @hidden */
  32771. _lodGenerationOffset: number;
  32772. /** @hidden */
  32773. _depthStencilTexture: Nullable<InternalTexture>;
  32774. /** @hidden */
  32775. _colorTextureArray: Nullable<WebGLTexture>;
  32776. /** @hidden */
  32777. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32778. /** @hidden */
  32779. _lodTextureHigh: Nullable<BaseTexture>;
  32780. /** @hidden */
  32781. _lodTextureMid: Nullable<BaseTexture>;
  32782. /** @hidden */
  32783. _lodTextureLow: Nullable<BaseTexture>;
  32784. /** @hidden */
  32785. _isRGBD: boolean;
  32786. /** @hidden */
  32787. _linearSpecularLOD: boolean;
  32788. /** @hidden */
  32789. _irradianceTexture: Nullable<BaseTexture>;
  32790. /** @hidden */
  32791. _webGLTexture: Nullable<WebGLTexture>;
  32792. /** @hidden */
  32793. _references: number;
  32794. private _engine;
  32795. /**
  32796. * Gets the Engine the texture belongs to.
  32797. * @returns The babylon engine
  32798. */
  32799. getEngine(): ThinEngine;
  32800. /**
  32801. * Gets the data source type of the texture
  32802. */
  32803. get source(): InternalTextureSource;
  32804. /**
  32805. * Creates a new InternalTexture
  32806. * @param engine defines the engine to use
  32807. * @param source defines the type of data that will be used
  32808. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32809. */
  32810. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32811. /**
  32812. * Increments the number of references (ie. the number of Texture that point to it)
  32813. */
  32814. incrementReferences(): void;
  32815. /**
  32816. * Change the size of the texture (not the size of the content)
  32817. * @param width defines the new width
  32818. * @param height defines the new height
  32819. * @param depth defines the new depth (1 by default)
  32820. */
  32821. updateSize(width: int, height: int, depth?: int): void;
  32822. /** @hidden */
  32823. _rebuild(): void;
  32824. /** @hidden */
  32825. _swapAndDie(target: InternalTexture): void;
  32826. /**
  32827. * Dispose the current allocated resources
  32828. */
  32829. dispose(): void;
  32830. }
  32831. }
  32832. declare module BABYLON {
  32833. /**
  32834. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32836. */
  32837. export class Analyser {
  32838. /**
  32839. * Gets or sets the smoothing
  32840. * @ignorenaming
  32841. */
  32842. SMOOTHING: number;
  32843. /**
  32844. * Gets or sets the FFT table size
  32845. * @ignorenaming
  32846. */
  32847. FFT_SIZE: number;
  32848. /**
  32849. * Gets or sets the bar graph amplitude
  32850. * @ignorenaming
  32851. */
  32852. BARGRAPHAMPLITUDE: number;
  32853. /**
  32854. * Gets or sets the position of the debug canvas
  32855. * @ignorenaming
  32856. */
  32857. DEBUGCANVASPOS: {
  32858. x: number;
  32859. y: number;
  32860. };
  32861. /**
  32862. * Gets or sets the debug canvas size
  32863. * @ignorenaming
  32864. */
  32865. DEBUGCANVASSIZE: {
  32866. width: number;
  32867. height: number;
  32868. };
  32869. private _byteFreqs;
  32870. private _byteTime;
  32871. private _floatFreqs;
  32872. private _webAudioAnalyser;
  32873. private _debugCanvas;
  32874. private _debugCanvasContext;
  32875. private _scene;
  32876. private _registerFunc;
  32877. private _audioEngine;
  32878. /**
  32879. * Creates a new analyser
  32880. * @param scene defines hosting scene
  32881. */
  32882. constructor(scene: Scene);
  32883. /**
  32884. * Get the number of data values you will have to play with for the visualization
  32885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32886. * @returns a number
  32887. */
  32888. getFrequencyBinCount(): number;
  32889. /**
  32890. * Gets the current frequency data as a byte array
  32891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32892. * @returns a Uint8Array
  32893. */
  32894. getByteFrequencyData(): Uint8Array;
  32895. /**
  32896. * Gets the current waveform as a byte array
  32897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32898. * @returns a Uint8Array
  32899. */
  32900. getByteTimeDomainData(): Uint8Array;
  32901. /**
  32902. * Gets the current frequency data as a float array
  32903. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32904. * @returns a Float32Array
  32905. */
  32906. getFloatFrequencyData(): Float32Array;
  32907. /**
  32908. * Renders the debug canvas
  32909. */
  32910. drawDebugCanvas(): void;
  32911. /**
  32912. * Stops rendering the debug canvas and removes it
  32913. */
  32914. stopDebugCanvas(): void;
  32915. /**
  32916. * Connects two audio nodes
  32917. * @param inputAudioNode defines first node to connect
  32918. * @param outputAudioNode defines second node to connect
  32919. */
  32920. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32921. /**
  32922. * Releases all associated resources
  32923. */
  32924. dispose(): void;
  32925. }
  32926. }
  32927. declare module BABYLON {
  32928. /**
  32929. * This represents an audio engine and it is responsible
  32930. * to play, synchronize and analyse sounds throughout the application.
  32931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32932. */
  32933. export interface IAudioEngine extends IDisposable {
  32934. /**
  32935. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32936. */
  32937. readonly canUseWebAudio: boolean;
  32938. /**
  32939. * Gets the current AudioContext if available.
  32940. */
  32941. readonly audioContext: Nullable<AudioContext>;
  32942. /**
  32943. * The master gain node defines the global audio volume of your audio engine.
  32944. */
  32945. readonly masterGain: GainNode;
  32946. /**
  32947. * Gets whether or not mp3 are supported by your browser.
  32948. */
  32949. readonly isMP3supported: boolean;
  32950. /**
  32951. * Gets whether or not ogg are supported by your browser.
  32952. */
  32953. readonly isOGGsupported: boolean;
  32954. /**
  32955. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32956. * @ignoreNaming
  32957. */
  32958. WarnedWebAudioUnsupported: boolean;
  32959. /**
  32960. * Defines if the audio engine relies on a custom unlocked button.
  32961. * In this case, the embedded button will not be displayed.
  32962. */
  32963. useCustomUnlockedButton: boolean;
  32964. /**
  32965. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32966. */
  32967. readonly unlocked: boolean;
  32968. /**
  32969. * Event raised when audio has been unlocked on the browser.
  32970. */
  32971. onAudioUnlockedObservable: Observable<AudioEngine>;
  32972. /**
  32973. * Event raised when audio has been locked on the browser.
  32974. */
  32975. onAudioLockedObservable: Observable<AudioEngine>;
  32976. /**
  32977. * Flags the audio engine in Locked state.
  32978. * This happens due to new browser policies preventing audio to autoplay.
  32979. */
  32980. lock(): void;
  32981. /**
  32982. * Unlocks the audio engine once a user action has been done on the dom.
  32983. * This is helpful to resume play once browser policies have been satisfied.
  32984. */
  32985. unlock(): void;
  32986. /**
  32987. * Gets the global volume sets on the master gain.
  32988. * @returns the global volume if set or -1 otherwise
  32989. */
  32990. getGlobalVolume(): number;
  32991. /**
  32992. * Sets the global volume of your experience (sets on the master gain).
  32993. * @param newVolume Defines the new global volume of the application
  32994. */
  32995. setGlobalVolume(newVolume: number): void;
  32996. /**
  32997. * Connect the audio engine to an audio analyser allowing some amazing
  32998. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33000. * @param analyser The analyser to connect to the engine
  33001. */
  33002. connectToAnalyser(analyser: Analyser): void;
  33003. }
  33004. /**
  33005. * This represents the default audio engine used in babylon.
  33006. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33008. */
  33009. export class AudioEngine implements IAudioEngine {
  33010. private _audioContext;
  33011. private _audioContextInitialized;
  33012. private _muteButton;
  33013. private _hostElement;
  33014. /**
  33015. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33016. */
  33017. canUseWebAudio: boolean;
  33018. /**
  33019. * The master gain node defines the global audio volume of your audio engine.
  33020. */
  33021. masterGain: GainNode;
  33022. /**
  33023. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33024. * @ignoreNaming
  33025. */
  33026. WarnedWebAudioUnsupported: boolean;
  33027. /**
  33028. * Gets whether or not mp3 are supported by your browser.
  33029. */
  33030. isMP3supported: boolean;
  33031. /**
  33032. * Gets whether or not ogg are supported by your browser.
  33033. */
  33034. isOGGsupported: boolean;
  33035. /**
  33036. * Gets whether audio has been unlocked on the device.
  33037. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33038. * a user interaction has happened.
  33039. */
  33040. unlocked: boolean;
  33041. /**
  33042. * Defines if the audio engine relies on a custom unlocked button.
  33043. * In this case, the embedded button will not be displayed.
  33044. */
  33045. useCustomUnlockedButton: boolean;
  33046. /**
  33047. * Event raised when audio has been unlocked on the browser.
  33048. */
  33049. onAudioUnlockedObservable: Observable<AudioEngine>;
  33050. /**
  33051. * Event raised when audio has been locked on the browser.
  33052. */
  33053. onAudioLockedObservable: Observable<AudioEngine>;
  33054. /**
  33055. * Gets the current AudioContext if available.
  33056. */
  33057. get audioContext(): Nullable<AudioContext>;
  33058. private _connectedAnalyser;
  33059. /**
  33060. * Instantiates a new audio engine.
  33061. *
  33062. * There should be only one per page as some browsers restrict the number
  33063. * of audio contexts you can create.
  33064. * @param hostElement defines the host element where to display the mute icon if necessary
  33065. */
  33066. constructor(hostElement?: Nullable<HTMLElement>);
  33067. /**
  33068. * Flags the audio engine in Locked state.
  33069. * This happens due to new browser policies preventing audio to autoplay.
  33070. */
  33071. lock(): void;
  33072. /**
  33073. * Unlocks the audio engine once a user action has been done on the dom.
  33074. * This is helpful to resume play once browser policies have been satisfied.
  33075. */
  33076. unlock(): void;
  33077. private _resumeAudioContext;
  33078. private _initializeAudioContext;
  33079. private _tryToRun;
  33080. private _triggerRunningState;
  33081. private _triggerSuspendedState;
  33082. private _displayMuteButton;
  33083. private _moveButtonToTopLeft;
  33084. private _onResize;
  33085. private _hideMuteButton;
  33086. /**
  33087. * Destroy and release the resources associated with the audio ccontext.
  33088. */
  33089. dispose(): void;
  33090. /**
  33091. * Gets the global volume sets on the master gain.
  33092. * @returns the global volume if set or -1 otherwise
  33093. */
  33094. getGlobalVolume(): number;
  33095. /**
  33096. * Sets the global volume of your experience (sets on the master gain).
  33097. * @param newVolume Defines the new global volume of the application
  33098. */
  33099. setGlobalVolume(newVolume: number): void;
  33100. /**
  33101. * Connect the audio engine to an audio analyser allowing some amazing
  33102. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33104. * @param analyser The analyser to connect to the engine
  33105. */
  33106. connectToAnalyser(analyser: Analyser): void;
  33107. }
  33108. }
  33109. declare module BABYLON {
  33110. /**
  33111. * Interface used to present a loading screen while loading a scene
  33112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33113. */
  33114. export interface ILoadingScreen {
  33115. /**
  33116. * Function called to display the loading screen
  33117. */
  33118. displayLoadingUI: () => void;
  33119. /**
  33120. * Function called to hide the loading screen
  33121. */
  33122. hideLoadingUI: () => void;
  33123. /**
  33124. * Gets or sets the color to use for the background
  33125. */
  33126. loadingUIBackgroundColor: string;
  33127. /**
  33128. * Gets or sets the text to display while loading
  33129. */
  33130. loadingUIText: string;
  33131. }
  33132. /**
  33133. * Class used for the default loading screen
  33134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33135. */
  33136. export class DefaultLoadingScreen implements ILoadingScreen {
  33137. private _renderingCanvas;
  33138. private _loadingText;
  33139. private _loadingDivBackgroundColor;
  33140. private _loadingDiv;
  33141. private _loadingTextDiv;
  33142. /** Gets or sets the logo url to use for the default loading screen */
  33143. static DefaultLogoUrl: string;
  33144. /** Gets or sets the spinner url to use for the default loading screen */
  33145. static DefaultSpinnerUrl: string;
  33146. /**
  33147. * Creates a new default loading screen
  33148. * @param _renderingCanvas defines the canvas used to render the scene
  33149. * @param _loadingText defines the default text to display
  33150. * @param _loadingDivBackgroundColor defines the default background color
  33151. */
  33152. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33153. /**
  33154. * Function called to display the loading screen
  33155. */
  33156. displayLoadingUI(): void;
  33157. /**
  33158. * Function called to hide the loading screen
  33159. */
  33160. hideLoadingUI(): void;
  33161. /**
  33162. * Gets or sets the text to display while loading
  33163. */
  33164. set loadingUIText(text: string);
  33165. get loadingUIText(): string;
  33166. /**
  33167. * Gets or sets the color to use for the background
  33168. */
  33169. get loadingUIBackgroundColor(): string;
  33170. set loadingUIBackgroundColor(color: string);
  33171. private _resizeLoadingUI;
  33172. }
  33173. }
  33174. declare module BABYLON {
  33175. /**
  33176. * Interface for any object that can request an animation frame
  33177. */
  33178. export interface ICustomAnimationFrameRequester {
  33179. /**
  33180. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33181. */
  33182. renderFunction?: Function;
  33183. /**
  33184. * Called to request the next frame to render to
  33185. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33186. */
  33187. requestAnimationFrame: Function;
  33188. /**
  33189. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33190. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33191. */
  33192. requestID?: number;
  33193. }
  33194. }
  33195. declare module BABYLON {
  33196. /**
  33197. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33198. */
  33199. export class PerformanceMonitor {
  33200. private _enabled;
  33201. private _rollingFrameTime;
  33202. private _lastFrameTimeMs;
  33203. /**
  33204. * constructor
  33205. * @param frameSampleSize The number of samples required to saturate the sliding window
  33206. */
  33207. constructor(frameSampleSize?: number);
  33208. /**
  33209. * Samples current frame
  33210. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33211. */
  33212. sampleFrame(timeMs?: number): void;
  33213. /**
  33214. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33215. */
  33216. get averageFrameTime(): number;
  33217. /**
  33218. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33219. */
  33220. get averageFrameTimeVariance(): number;
  33221. /**
  33222. * Returns the frame time of the most recent frame
  33223. */
  33224. get instantaneousFrameTime(): number;
  33225. /**
  33226. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33227. */
  33228. get averageFPS(): number;
  33229. /**
  33230. * Returns the average framerate in frames per second using the most recent frame time
  33231. */
  33232. get instantaneousFPS(): number;
  33233. /**
  33234. * Returns true if enough samples have been taken to completely fill the sliding window
  33235. */
  33236. get isSaturated(): boolean;
  33237. /**
  33238. * Enables contributions to the sliding window sample set
  33239. */
  33240. enable(): void;
  33241. /**
  33242. * Disables contributions to the sliding window sample set
  33243. * Samples will not be interpolated over the disabled period
  33244. */
  33245. disable(): void;
  33246. /**
  33247. * Returns true if sampling is enabled
  33248. */
  33249. get isEnabled(): boolean;
  33250. /**
  33251. * Resets performance monitor
  33252. */
  33253. reset(): void;
  33254. }
  33255. /**
  33256. * RollingAverage
  33257. *
  33258. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33259. */
  33260. export class RollingAverage {
  33261. /**
  33262. * Current average
  33263. */
  33264. average: number;
  33265. /**
  33266. * Current variance
  33267. */
  33268. variance: number;
  33269. protected _samples: Array<number>;
  33270. protected _sampleCount: number;
  33271. protected _pos: number;
  33272. protected _m2: number;
  33273. /**
  33274. * constructor
  33275. * @param length The number of samples required to saturate the sliding window
  33276. */
  33277. constructor(length: number);
  33278. /**
  33279. * Adds a sample to the sample set
  33280. * @param v The sample value
  33281. */
  33282. add(v: number): void;
  33283. /**
  33284. * Returns previously added values or null if outside of history or outside the sliding window domain
  33285. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33286. * @return Value previously recorded with add() or null if outside of range
  33287. */
  33288. history(i: number): number;
  33289. /**
  33290. * Returns true if enough samples have been taken to completely fill the sliding window
  33291. * @return true if sample-set saturated
  33292. */
  33293. isSaturated(): boolean;
  33294. /**
  33295. * Resets the rolling average (equivalent to 0 samples taken so far)
  33296. */
  33297. reset(): void;
  33298. /**
  33299. * Wraps a value around the sample range boundaries
  33300. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33301. * @return Wrapped position in sample range
  33302. */
  33303. protected _wrapPosition(i: number): number;
  33304. }
  33305. }
  33306. declare module BABYLON {
  33307. /**
  33308. * This class is used to track a performance counter which is number based.
  33309. * The user has access to many properties which give statistics of different nature.
  33310. *
  33311. * The implementer can track two kinds of Performance Counter: time and count.
  33312. * 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.
  33313. * 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.
  33314. */
  33315. export class PerfCounter {
  33316. /**
  33317. * Gets or sets a global boolean to turn on and off all the counters
  33318. */
  33319. static Enabled: boolean;
  33320. /**
  33321. * Returns the smallest value ever
  33322. */
  33323. get min(): number;
  33324. /**
  33325. * Returns the biggest value ever
  33326. */
  33327. get max(): number;
  33328. /**
  33329. * Returns the average value since the performance counter is running
  33330. */
  33331. get average(): number;
  33332. /**
  33333. * Returns the average value of the last second the counter was monitored
  33334. */
  33335. get lastSecAverage(): number;
  33336. /**
  33337. * Returns the current value
  33338. */
  33339. get current(): number;
  33340. /**
  33341. * Gets the accumulated total
  33342. */
  33343. get total(): number;
  33344. /**
  33345. * Gets the total value count
  33346. */
  33347. get count(): number;
  33348. /**
  33349. * Creates a new counter
  33350. */
  33351. constructor();
  33352. /**
  33353. * Call this method to start monitoring a new frame.
  33354. * 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.
  33355. */
  33356. fetchNewFrame(): void;
  33357. /**
  33358. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33359. * @param newCount the count value to add to the monitored count
  33360. * @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.
  33361. */
  33362. addCount(newCount: number, fetchResult: boolean): void;
  33363. /**
  33364. * Start monitoring this performance counter
  33365. */
  33366. beginMonitoring(): void;
  33367. /**
  33368. * Compute the time lapsed since the previous beginMonitoring() call.
  33369. * @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
  33370. */
  33371. endMonitoring(newFrame?: boolean): void;
  33372. private _fetchResult;
  33373. private _startMonitoringTime;
  33374. private _min;
  33375. private _max;
  33376. private _average;
  33377. private _current;
  33378. private _totalValueCount;
  33379. private _totalAccumulated;
  33380. private _lastSecAverage;
  33381. private _lastSecAccumulated;
  33382. private _lastSecTime;
  33383. private _lastSecValueCount;
  33384. }
  33385. }
  33386. declare module BABYLON {
  33387. interface ThinEngine {
  33388. /**
  33389. * Sets alpha constants used by some alpha blending modes
  33390. * @param r defines the red component
  33391. * @param g defines the green component
  33392. * @param b defines the blue component
  33393. * @param a defines the alpha component
  33394. */
  33395. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33396. /**
  33397. * Sets the current alpha mode
  33398. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33399. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33400. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33401. */
  33402. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33403. /**
  33404. * Gets the current alpha mode
  33405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33406. * @returns the current alpha mode
  33407. */
  33408. getAlphaMode(): number;
  33409. /**
  33410. * Sets the current alpha equation
  33411. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33412. */
  33413. setAlphaEquation(equation: number): void;
  33414. /**
  33415. * Gets the current alpha equation.
  33416. * @returns the current alpha equation
  33417. */
  33418. getAlphaEquation(): number;
  33419. }
  33420. }
  33421. declare module BABYLON {
  33422. /**
  33423. * Defines the interface used by display changed events
  33424. */
  33425. export interface IDisplayChangedEventArgs {
  33426. /** Gets the vrDisplay object (if any) */
  33427. vrDisplay: Nullable<any>;
  33428. /** Gets a boolean indicating if webVR is supported */
  33429. vrSupported: boolean;
  33430. }
  33431. /**
  33432. * Defines the interface used by objects containing a viewport (like a camera)
  33433. */
  33434. interface IViewportOwnerLike {
  33435. /**
  33436. * Gets or sets the viewport
  33437. */
  33438. viewport: IViewportLike;
  33439. }
  33440. /**
  33441. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33442. */
  33443. export class Engine extends ThinEngine {
  33444. /** Defines that alpha blending is disabled */
  33445. static readonly ALPHA_DISABLE: number;
  33446. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33447. static readonly ALPHA_ADD: number;
  33448. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33449. static readonly ALPHA_COMBINE: number;
  33450. /** Defines that alpha blending to DEST - SRC * DEST */
  33451. static readonly ALPHA_SUBTRACT: number;
  33452. /** Defines that alpha blending to SRC * DEST */
  33453. static readonly ALPHA_MULTIPLY: number;
  33454. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33455. static readonly ALPHA_MAXIMIZED: number;
  33456. /** Defines that alpha blending to SRC + DEST */
  33457. static readonly ALPHA_ONEONE: number;
  33458. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33459. static readonly ALPHA_PREMULTIPLIED: number;
  33460. /**
  33461. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33462. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33463. */
  33464. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33465. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33466. static readonly ALPHA_INTERPOLATE: number;
  33467. /**
  33468. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33469. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33470. */
  33471. static readonly ALPHA_SCREENMODE: number;
  33472. /** Defines that the ressource is not delayed*/
  33473. static readonly DELAYLOADSTATE_NONE: number;
  33474. /** Defines that the ressource was successfully delay loaded */
  33475. static readonly DELAYLOADSTATE_LOADED: number;
  33476. /** Defines that the ressource is currently delay loading */
  33477. static readonly DELAYLOADSTATE_LOADING: number;
  33478. /** Defines that the ressource is delayed and has not started loading */
  33479. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33481. static readonly NEVER: number;
  33482. /** 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 */
  33483. static readonly ALWAYS: number;
  33484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33485. static readonly LESS: number;
  33486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33487. static readonly EQUAL: number;
  33488. /** 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 */
  33489. static readonly LEQUAL: number;
  33490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33491. static readonly GREATER: number;
  33492. /** 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 */
  33493. static readonly GEQUAL: number;
  33494. /** 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 */
  33495. static readonly NOTEQUAL: number;
  33496. /** Passed to stencilOperation to specify that stencil value must be kept */
  33497. static readonly KEEP: number;
  33498. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33499. static readonly REPLACE: number;
  33500. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33501. static readonly INCR: number;
  33502. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33503. static readonly DECR: number;
  33504. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33505. static readonly INVERT: number;
  33506. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33507. static readonly INCR_WRAP: number;
  33508. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33509. static readonly DECR_WRAP: number;
  33510. /** Texture is not repeating outside of 0..1 UVs */
  33511. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33512. /** Texture is repeating outside of 0..1 UVs */
  33513. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33514. /** Texture is repeating and mirrored */
  33515. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33516. /** ALPHA */
  33517. static readonly TEXTUREFORMAT_ALPHA: number;
  33518. /** LUMINANCE */
  33519. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33520. /** LUMINANCE_ALPHA */
  33521. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33522. /** RGB */
  33523. static readonly TEXTUREFORMAT_RGB: number;
  33524. /** RGBA */
  33525. static readonly TEXTUREFORMAT_RGBA: number;
  33526. /** RED */
  33527. static readonly TEXTUREFORMAT_RED: number;
  33528. /** RED (2nd reference) */
  33529. static readonly TEXTUREFORMAT_R: number;
  33530. /** RG */
  33531. static readonly TEXTUREFORMAT_RG: number;
  33532. /** RED_INTEGER */
  33533. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33534. /** RED_INTEGER (2nd reference) */
  33535. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33536. /** RG_INTEGER */
  33537. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33538. /** RGB_INTEGER */
  33539. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33540. /** RGBA_INTEGER */
  33541. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33542. /** UNSIGNED_BYTE */
  33543. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33544. /** UNSIGNED_BYTE (2nd reference) */
  33545. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33546. /** FLOAT */
  33547. static readonly TEXTURETYPE_FLOAT: number;
  33548. /** HALF_FLOAT */
  33549. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33550. /** BYTE */
  33551. static readonly TEXTURETYPE_BYTE: number;
  33552. /** SHORT */
  33553. static readonly TEXTURETYPE_SHORT: number;
  33554. /** UNSIGNED_SHORT */
  33555. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33556. /** INT */
  33557. static readonly TEXTURETYPE_INT: number;
  33558. /** UNSIGNED_INT */
  33559. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33560. /** UNSIGNED_SHORT_4_4_4_4 */
  33561. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33562. /** UNSIGNED_SHORT_5_5_5_1 */
  33563. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33564. /** UNSIGNED_SHORT_5_6_5 */
  33565. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33566. /** UNSIGNED_INT_2_10_10_10_REV */
  33567. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33568. /** UNSIGNED_INT_24_8 */
  33569. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33570. /** UNSIGNED_INT_10F_11F_11F_REV */
  33571. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33572. /** UNSIGNED_INT_5_9_9_9_REV */
  33573. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33574. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33575. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33576. /** nearest is mag = nearest and min = nearest and mip = linear */
  33577. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33578. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33579. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33580. /** Trilinear is mag = linear and min = linear and mip = linear */
  33581. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33582. /** nearest is mag = nearest and min = nearest and mip = linear */
  33583. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33584. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33585. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33586. /** Trilinear is mag = linear and min = linear and mip = linear */
  33587. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33588. /** mag = nearest and min = nearest and mip = nearest */
  33589. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33590. /** mag = nearest and min = linear and mip = nearest */
  33591. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33592. /** mag = nearest and min = linear and mip = linear */
  33593. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33594. /** mag = nearest and min = linear and mip = none */
  33595. static readonly TEXTURE_NEAREST_LINEAR: number;
  33596. /** mag = nearest and min = nearest and mip = none */
  33597. static readonly TEXTURE_NEAREST_NEAREST: number;
  33598. /** mag = linear and min = nearest and mip = nearest */
  33599. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33600. /** mag = linear and min = nearest and mip = linear */
  33601. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33602. /** mag = linear and min = linear and mip = none */
  33603. static readonly TEXTURE_LINEAR_LINEAR: number;
  33604. /** mag = linear and min = nearest and mip = none */
  33605. static readonly TEXTURE_LINEAR_NEAREST: number;
  33606. /** Explicit coordinates mode */
  33607. static readonly TEXTURE_EXPLICIT_MODE: number;
  33608. /** Spherical coordinates mode */
  33609. static readonly TEXTURE_SPHERICAL_MODE: number;
  33610. /** Planar coordinates mode */
  33611. static readonly TEXTURE_PLANAR_MODE: number;
  33612. /** Cubic coordinates mode */
  33613. static readonly TEXTURE_CUBIC_MODE: number;
  33614. /** Projection coordinates mode */
  33615. static readonly TEXTURE_PROJECTION_MODE: number;
  33616. /** Skybox coordinates mode */
  33617. static readonly TEXTURE_SKYBOX_MODE: number;
  33618. /** Inverse Cubic coordinates mode */
  33619. static readonly TEXTURE_INVCUBIC_MODE: number;
  33620. /** Equirectangular coordinates mode */
  33621. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33622. /** Equirectangular Fixed coordinates mode */
  33623. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33624. /** Equirectangular Fixed Mirrored coordinates mode */
  33625. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33626. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33627. static readonly SCALEMODE_FLOOR: number;
  33628. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33629. static readonly SCALEMODE_NEAREST: number;
  33630. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33631. static readonly SCALEMODE_CEILING: number;
  33632. /**
  33633. * Returns the current npm package of the sdk
  33634. */
  33635. static get NpmPackage(): string;
  33636. /**
  33637. * Returns the current version of the framework
  33638. */
  33639. static get Version(): string;
  33640. /** Gets the list of created engines */
  33641. static get Instances(): Engine[];
  33642. /**
  33643. * Gets the latest created engine
  33644. */
  33645. static get LastCreatedEngine(): Nullable<Engine>;
  33646. /**
  33647. * Gets the latest created scene
  33648. */
  33649. static get LastCreatedScene(): Nullable<Scene>;
  33650. /**
  33651. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33652. * @param flag defines which part of the materials must be marked as dirty
  33653. * @param predicate defines a predicate used to filter which materials should be affected
  33654. */
  33655. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33656. /**
  33657. * Method called to create the default loading screen.
  33658. * This can be overriden in your own app.
  33659. * @param canvas The rendering canvas element
  33660. * @returns The loading screen
  33661. */
  33662. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33663. /**
  33664. * Method called to create the default rescale post process on each engine.
  33665. */
  33666. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33667. /**
  33668. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33669. **/
  33670. enableOfflineSupport: boolean;
  33671. /**
  33672. * 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)
  33673. **/
  33674. disableManifestCheck: boolean;
  33675. /**
  33676. * Gets the list of created scenes
  33677. */
  33678. scenes: Scene[];
  33679. /**
  33680. * Event raised when a new scene is created
  33681. */
  33682. onNewSceneAddedObservable: Observable<Scene>;
  33683. /**
  33684. * Gets the list of created postprocesses
  33685. */
  33686. postProcesses: PostProcess[];
  33687. /**
  33688. * Gets a boolean indicating if the pointer is currently locked
  33689. */
  33690. isPointerLock: boolean;
  33691. /**
  33692. * Observable event triggered each time the rendering canvas is resized
  33693. */
  33694. onResizeObservable: Observable<Engine>;
  33695. /**
  33696. * Observable event triggered each time the canvas loses focus
  33697. */
  33698. onCanvasBlurObservable: Observable<Engine>;
  33699. /**
  33700. * Observable event triggered each time the canvas gains focus
  33701. */
  33702. onCanvasFocusObservable: Observable<Engine>;
  33703. /**
  33704. * Observable event triggered each time the canvas receives pointerout event
  33705. */
  33706. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33707. /**
  33708. * Observable raised when the engine begins a new frame
  33709. */
  33710. onBeginFrameObservable: Observable<Engine>;
  33711. /**
  33712. * If set, will be used to request the next animation frame for the render loop
  33713. */
  33714. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33715. /**
  33716. * Observable raised when the engine ends the current frame
  33717. */
  33718. onEndFrameObservable: Observable<Engine>;
  33719. /**
  33720. * Observable raised when the engine is about to compile a shader
  33721. */
  33722. onBeforeShaderCompilationObservable: Observable<Engine>;
  33723. /**
  33724. * Observable raised when the engine has jsut compiled a shader
  33725. */
  33726. onAfterShaderCompilationObservable: Observable<Engine>;
  33727. /**
  33728. * Gets the audio engine
  33729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33730. * @ignorenaming
  33731. */
  33732. static audioEngine: IAudioEngine;
  33733. /**
  33734. * Default AudioEngine factory responsible of creating the Audio Engine.
  33735. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33736. */
  33737. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33738. /**
  33739. * Default offline support factory responsible of creating a tool used to store data locally.
  33740. * By default, this will create a Database object if the workload has been embedded.
  33741. */
  33742. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33743. private _loadingScreen;
  33744. private _pointerLockRequested;
  33745. private _dummyFramebuffer;
  33746. private _rescalePostProcess;
  33747. private _deterministicLockstep;
  33748. private _lockstepMaxSteps;
  33749. private _timeStep;
  33750. protected get _supportsHardwareTextureRescaling(): boolean;
  33751. private _fps;
  33752. private _deltaTime;
  33753. /** @hidden */
  33754. _drawCalls: PerfCounter;
  33755. /** 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 */
  33756. canvasTabIndex: number;
  33757. /**
  33758. * Turn this value on if you want to pause FPS computation when in background
  33759. */
  33760. disablePerformanceMonitorInBackground: boolean;
  33761. private _performanceMonitor;
  33762. /**
  33763. * Gets the performance monitor attached to this engine
  33764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33765. */
  33766. get performanceMonitor(): PerformanceMonitor;
  33767. private _onFocus;
  33768. private _onBlur;
  33769. private _onCanvasPointerOut;
  33770. private _onCanvasBlur;
  33771. private _onCanvasFocus;
  33772. private _onFullscreenChange;
  33773. private _onPointerLockChange;
  33774. /**
  33775. * Gets the HTML element used to attach event listeners
  33776. * @returns a HTML element
  33777. */
  33778. getInputElement(): Nullable<HTMLElement>;
  33779. /**
  33780. * Creates a new engine
  33781. * @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
  33782. * @param antialias defines enable antialiasing (default: false)
  33783. * @param options defines further options to be sent to the getContext() function
  33784. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33785. */
  33786. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33787. /**
  33788. * Gets current aspect ratio
  33789. * @param viewportOwner defines the camera to use to get the aspect ratio
  33790. * @param useScreen defines if screen size must be used (or the current render target if any)
  33791. * @returns a number defining the aspect ratio
  33792. */
  33793. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33794. /**
  33795. * Gets current screen aspect ratio
  33796. * @returns a number defining the aspect ratio
  33797. */
  33798. getScreenAspectRatio(): number;
  33799. /**
  33800. * Gets the client rect of the HTML canvas attached with the current webGL context
  33801. * @returns a client rectanglee
  33802. */
  33803. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33804. /**
  33805. * Gets the client rect of the HTML element used for events
  33806. * @returns a client rectanglee
  33807. */
  33808. getInputElementClientRect(): Nullable<ClientRect>;
  33809. /**
  33810. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33811. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33812. * @returns true if engine is in deterministic lock step mode
  33813. */
  33814. isDeterministicLockStep(): boolean;
  33815. /**
  33816. * Gets the max steps when engine is running in deterministic lock step
  33817. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33818. * @returns the max steps
  33819. */
  33820. getLockstepMaxSteps(): number;
  33821. /**
  33822. * Returns the time in ms between steps when using deterministic lock step.
  33823. * @returns time step in (ms)
  33824. */
  33825. getTimeStep(): number;
  33826. /**
  33827. * Force the mipmap generation for the given render target texture
  33828. * @param texture defines the render target texture to use
  33829. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33830. */
  33831. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33832. /** States */
  33833. /**
  33834. * Set various states to the webGL context
  33835. * @param culling defines backface culling state
  33836. * @param zOffset defines the value to apply to zOffset (0 by default)
  33837. * @param force defines if states must be applied even if cache is up to date
  33838. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33839. */
  33840. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33841. /**
  33842. * Set the z offset to apply to current rendering
  33843. * @param value defines the offset to apply
  33844. */
  33845. setZOffset(value: number): void;
  33846. /**
  33847. * Gets the current value of the zOffset
  33848. * @returns the current zOffset state
  33849. */
  33850. getZOffset(): number;
  33851. /**
  33852. * Enable or disable depth buffering
  33853. * @param enable defines the state to set
  33854. */
  33855. setDepthBuffer(enable: boolean): void;
  33856. /**
  33857. * Gets a boolean indicating if depth writing is enabled
  33858. * @returns the current depth writing state
  33859. */
  33860. getDepthWrite(): boolean;
  33861. /**
  33862. * Enable or disable depth writing
  33863. * @param enable defines the state to set
  33864. */
  33865. setDepthWrite(enable: boolean): void;
  33866. /**
  33867. * Gets a boolean indicating if stencil buffer is enabled
  33868. * @returns the current stencil buffer state
  33869. */
  33870. getStencilBuffer(): boolean;
  33871. /**
  33872. * Enable or disable the stencil buffer
  33873. * @param enable defines if the stencil buffer must be enabled or disabled
  33874. */
  33875. setStencilBuffer(enable: boolean): void;
  33876. /**
  33877. * Gets the current stencil mask
  33878. * @returns a number defining the new stencil mask to use
  33879. */
  33880. getStencilMask(): number;
  33881. /**
  33882. * Sets the current stencil mask
  33883. * @param mask defines the new stencil mask to use
  33884. */
  33885. setStencilMask(mask: number): void;
  33886. /**
  33887. * Gets the current stencil function
  33888. * @returns a number defining the stencil function to use
  33889. */
  33890. getStencilFunction(): number;
  33891. /**
  33892. * Gets the current stencil reference value
  33893. * @returns a number defining the stencil reference value to use
  33894. */
  33895. getStencilFunctionReference(): number;
  33896. /**
  33897. * Gets the current stencil mask
  33898. * @returns a number defining the stencil mask to use
  33899. */
  33900. getStencilFunctionMask(): number;
  33901. /**
  33902. * Sets the current stencil function
  33903. * @param stencilFunc defines the new stencil function to use
  33904. */
  33905. setStencilFunction(stencilFunc: number): void;
  33906. /**
  33907. * Sets the current stencil reference
  33908. * @param reference defines the new stencil reference to use
  33909. */
  33910. setStencilFunctionReference(reference: number): void;
  33911. /**
  33912. * Sets the current stencil mask
  33913. * @param mask defines the new stencil mask to use
  33914. */
  33915. setStencilFunctionMask(mask: number): void;
  33916. /**
  33917. * Gets the current stencil operation when stencil fails
  33918. * @returns a number defining stencil operation to use when stencil fails
  33919. */
  33920. getStencilOperationFail(): number;
  33921. /**
  33922. * Gets the current stencil operation when depth fails
  33923. * @returns a number defining stencil operation to use when depth fails
  33924. */
  33925. getStencilOperationDepthFail(): number;
  33926. /**
  33927. * Gets the current stencil operation when stencil passes
  33928. * @returns a number defining stencil operation to use when stencil passes
  33929. */
  33930. getStencilOperationPass(): number;
  33931. /**
  33932. * Sets the stencil operation to use when stencil fails
  33933. * @param operation defines the stencil operation to use when stencil fails
  33934. */
  33935. setStencilOperationFail(operation: number): void;
  33936. /**
  33937. * Sets the stencil operation to use when depth fails
  33938. * @param operation defines the stencil operation to use when depth fails
  33939. */
  33940. setStencilOperationDepthFail(operation: number): void;
  33941. /**
  33942. * Sets the stencil operation to use when stencil passes
  33943. * @param operation defines the stencil operation to use when stencil passes
  33944. */
  33945. setStencilOperationPass(operation: number): void;
  33946. /**
  33947. * Sets a boolean indicating if the dithering state is enabled or disabled
  33948. * @param value defines the dithering state
  33949. */
  33950. setDitheringState(value: boolean): void;
  33951. /**
  33952. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33953. * @param value defines the rasterizer state
  33954. */
  33955. setRasterizerState(value: boolean): void;
  33956. /**
  33957. * Gets the current depth function
  33958. * @returns a number defining the depth function
  33959. */
  33960. getDepthFunction(): Nullable<number>;
  33961. /**
  33962. * Sets the current depth function
  33963. * @param depthFunc defines the function to use
  33964. */
  33965. setDepthFunction(depthFunc: number): void;
  33966. /**
  33967. * Sets the current depth function to GREATER
  33968. */
  33969. setDepthFunctionToGreater(): void;
  33970. /**
  33971. * Sets the current depth function to GEQUAL
  33972. */
  33973. setDepthFunctionToGreaterOrEqual(): void;
  33974. /**
  33975. * Sets the current depth function to LESS
  33976. */
  33977. setDepthFunctionToLess(): void;
  33978. /**
  33979. * Sets the current depth function to LEQUAL
  33980. */
  33981. setDepthFunctionToLessOrEqual(): void;
  33982. private _cachedStencilBuffer;
  33983. private _cachedStencilFunction;
  33984. private _cachedStencilMask;
  33985. private _cachedStencilOperationPass;
  33986. private _cachedStencilOperationFail;
  33987. private _cachedStencilOperationDepthFail;
  33988. private _cachedStencilReference;
  33989. /**
  33990. * Caches the the state of the stencil buffer
  33991. */
  33992. cacheStencilState(): void;
  33993. /**
  33994. * Restores the state of the stencil buffer
  33995. */
  33996. restoreStencilState(): void;
  33997. /**
  33998. * Directly set the WebGL Viewport
  33999. * @param x defines the x coordinate of the viewport (in screen space)
  34000. * @param y defines the y coordinate of the viewport (in screen space)
  34001. * @param width defines the width of the viewport (in screen space)
  34002. * @param height defines the height of the viewport (in screen space)
  34003. * @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
  34004. */
  34005. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34006. /**
  34007. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34008. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34009. * @param y defines the y-coordinate of the corner of the clear rectangle
  34010. * @param width defines the width of the clear rectangle
  34011. * @param height defines the height of the clear rectangle
  34012. * @param clearColor defines the clear color
  34013. */
  34014. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34015. /**
  34016. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34017. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34018. * @param y defines the y-coordinate of the corner of the clear rectangle
  34019. * @param width defines the width of the clear rectangle
  34020. * @param height defines the height of the clear rectangle
  34021. */
  34022. enableScissor(x: number, y: number, width: number, height: number): void;
  34023. /**
  34024. * Disable previously set scissor test rectangle
  34025. */
  34026. disableScissor(): void;
  34027. protected _reportDrawCall(): void;
  34028. /**
  34029. * Initializes a webVR display and starts listening to display change events
  34030. * The onVRDisplayChangedObservable will be notified upon these changes
  34031. * @returns The onVRDisplayChangedObservable
  34032. */
  34033. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34034. /** @hidden */
  34035. _prepareVRComponent(): void;
  34036. /** @hidden */
  34037. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34038. /** @hidden */
  34039. _submitVRFrame(): void;
  34040. /**
  34041. * Call this function to leave webVR mode
  34042. * Will do nothing if webVR is not supported or if there is no webVR device
  34043. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34044. */
  34045. disableVR(): void;
  34046. /**
  34047. * Gets a boolean indicating that the system is in VR mode and is presenting
  34048. * @returns true if VR mode is engaged
  34049. */
  34050. isVRPresenting(): boolean;
  34051. /** @hidden */
  34052. _requestVRFrame(): void;
  34053. /** @hidden */
  34054. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34055. /**
  34056. * Gets the source code of the vertex shader associated with a specific webGL program
  34057. * @param program defines the program to use
  34058. * @returns a string containing the source code of the vertex shader associated with the program
  34059. */
  34060. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34061. /**
  34062. * Gets the source code of the fragment shader associated with a specific webGL program
  34063. * @param program defines the program to use
  34064. * @returns a string containing the source code of the fragment shader associated with the program
  34065. */
  34066. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34067. /**
  34068. * Sets a depth stencil texture from a render target to the according uniform.
  34069. * @param channel The texture channel
  34070. * @param uniform The uniform to set
  34071. * @param texture The render target texture containing the depth stencil texture to apply
  34072. */
  34073. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34074. /**
  34075. * Sets a texture to the webGL context from a postprocess
  34076. * @param channel defines the channel to use
  34077. * @param postProcess defines the source postprocess
  34078. */
  34079. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34080. /**
  34081. * Binds the output of the passed in post process to the texture channel specified
  34082. * @param channel The channel the texture should be bound to
  34083. * @param postProcess The post process which's output should be bound
  34084. */
  34085. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34086. /** @hidden */
  34087. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34088. protected _rebuildBuffers(): void;
  34089. /** @hidden */
  34090. _renderFrame(): void;
  34091. _renderLoop(): void;
  34092. /** @hidden */
  34093. _renderViews(): boolean;
  34094. /**
  34095. * Toggle full screen mode
  34096. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34097. */
  34098. switchFullscreen(requestPointerLock: boolean): void;
  34099. /**
  34100. * Enters full screen mode
  34101. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34102. */
  34103. enterFullscreen(requestPointerLock: boolean): void;
  34104. /**
  34105. * Exits full screen mode
  34106. */
  34107. exitFullscreen(): void;
  34108. /**
  34109. * Enters Pointerlock mode
  34110. */
  34111. enterPointerlock(): void;
  34112. /**
  34113. * Exits Pointerlock mode
  34114. */
  34115. exitPointerlock(): void;
  34116. /**
  34117. * Begin a new frame
  34118. */
  34119. beginFrame(): void;
  34120. /**
  34121. * Enf the current frame
  34122. */
  34123. endFrame(): void;
  34124. resize(): void;
  34125. /**
  34126. * Force a specific size of the canvas
  34127. * @param width defines the new canvas' width
  34128. * @param height defines the new canvas' height
  34129. */
  34130. setSize(width: number, height: number): void;
  34131. /**
  34132. * Updates a dynamic vertex buffer.
  34133. * @param vertexBuffer the vertex buffer to update
  34134. * @param data the data used to update the vertex buffer
  34135. * @param byteOffset the byte offset of the data
  34136. * @param byteLength the byte length of the data
  34137. */
  34138. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34139. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34140. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34141. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34142. _releaseTexture(texture: InternalTexture): void;
  34143. /**
  34144. * @hidden
  34145. * Rescales a texture
  34146. * @param source input texutre
  34147. * @param destination destination texture
  34148. * @param scene scene to use to render the resize
  34149. * @param internalFormat format to use when resizing
  34150. * @param onComplete callback to be called when resize has completed
  34151. */
  34152. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34153. /**
  34154. * Gets the current framerate
  34155. * @returns a number representing the framerate
  34156. */
  34157. getFps(): number;
  34158. /**
  34159. * Gets the time spent between current and previous frame
  34160. * @returns a number representing the delta time in ms
  34161. */
  34162. getDeltaTime(): number;
  34163. private _measureFps;
  34164. /** @hidden */
  34165. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34166. /**
  34167. * Update a dynamic index buffer
  34168. * @param indexBuffer defines the target index buffer
  34169. * @param indices defines the data to update
  34170. * @param offset defines the offset in the target index buffer where update should start
  34171. */
  34172. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34173. /**
  34174. * Updates the sample count of a render target texture
  34175. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34176. * @param texture defines the texture to update
  34177. * @param samples defines the sample count to set
  34178. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34179. */
  34180. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34181. /**
  34182. * Updates a depth texture Comparison Mode and Function.
  34183. * If the comparison Function is equal to 0, the mode will be set to none.
  34184. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34185. * @param texture The texture to set the comparison function for
  34186. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34187. */
  34188. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34189. /**
  34190. * Creates a webGL buffer to use with instanciation
  34191. * @param capacity defines the size of the buffer
  34192. * @returns the webGL buffer
  34193. */
  34194. createInstancesBuffer(capacity: number): DataBuffer;
  34195. /**
  34196. * Delete a webGL buffer used with instanciation
  34197. * @param buffer defines the webGL buffer to delete
  34198. */
  34199. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34200. private _clientWaitAsync;
  34201. /** @hidden */
  34202. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34203. /** @hidden */
  34204. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34205. dispose(): void;
  34206. private _disableTouchAction;
  34207. /**
  34208. * Display the loading screen
  34209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34210. */
  34211. displayLoadingUI(): void;
  34212. /**
  34213. * Hide the loading screen
  34214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34215. */
  34216. hideLoadingUI(): void;
  34217. /**
  34218. * Gets the current loading screen object
  34219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34220. */
  34221. get loadingScreen(): ILoadingScreen;
  34222. /**
  34223. * Sets the current loading screen object
  34224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34225. */
  34226. set loadingScreen(loadingScreen: ILoadingScreen);
  34227. /**
  34228. * Sets the current loading screen text
  34229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34230. */
  34231. set loadingUIText(text: string);
  34232. /**
  34233. * Sets the current loading screen background color
  34234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34235. */
  34236. set loadingUIBackgroundColor(color: string);
  34237. /** Pointerlock and fullscreen */
  34238. /**
  34239. * Ask the browser to promote the current element to pointerlock mode
  34240. * @param element defines the DOM element to promote
  34241. */
  34242. static _RequestPointerlock(element: HTMLElement): void;
  34243. /**
  34244. * Asks the browser to exit pointerlock mode
  34245. */
  34246. static _ExitPointerlock(): void;
  34247. /**
  34248. * Ask the browser to promote the current element to fullscreen rendering mode
  34249. * @param element defines the DOM element to promote
  34250. */
  34251. static _RequestFullscreen(element: HTMLElement): void;
  34252. /**
  34253. * Asks the browser to exit fullscreen mode
  34254. */
  34255. static _ExitFullscreen(): void;
  34256. }
  34257. }
  34258. declare module BABYLON {
  34259. /**
  34260. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34261. * during the life time of the application.
  34262. */
  34263. export class EngineStore {
  34264. /** Gets the list of created engines */
  34265. static Instances: Engine[];
  34266. /** @hidden */
  34267. static _LastCreatedScene: Nullable<Scene>;
  34268. /**
  34269. * Gets the latest created engine
  34270. */
  34271. static get LastCreatedEngine(): Nullable<Engine>;
  34272. /**
  34273. * Gets the latest created scene
  34274. */
  34275. static get LastCreatedScene(): Nullable<Scene>;
  34276. /**
  34277. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34278. * @ignorenaming
  34279. */
  34280. static UseFallbackTexture: boolean;
  34281. /**
  34282. * Texture content used if a texture cannot loaded
  34283. * @ignorenaming
  34284. */
  34285. static FallbackTexture: string;
  34286. }
  34287. }
  34288. declare module BABYLON {
  34289. /**
  34290. * Helper class that provides a small promise polyfill
  34291. */
  34292. export class PromisePolyfill {
  34293. /**
  34294. * Static function used to check if the polyfill is required
  34295. * If this is the case then the function will inject the polyfill to window.Promise
  34296. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34297. */
  34298. static Apply(force?: boolean): void;
  34299. }
  34300. }
  34301. declare module BABYLON {
  34302. /**
  34303. * Interface for screenshot methods with describe argument called `size` as object with options
  34304. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34305. */
  34306. export interface IScreenshotSize {
  34307. /**
  34308. * number in pixels for canvas height
  34309. */
  34310. height?: number;
  34311. /**
  34312. * multiplier allowing render at a higher or lower resolution
  34313. * If value is defined then height and width will be ignored and taken from camera
  34314. */
  34315. precision?: number;
  34316. /**
  34317. * number in pixels for canvas width
  34318. */
  34319. width?: number;
  34320. }
  34321. }
  34322. declare module BABYLON {
  34323. interface IColor4Like {
  34324. r: float;
  34325. g: float;
  34326. b: float;
  34327. a: float;
  34328. }
  34329. /**
  34330. * Class containing a set of static utilities functions
  34331. */
  34332. export class Tools {
  34333. /**
  34334. * Gets or sets the base URL to use to load assets
  34335. */
  34336. static get BaseUrl(): string;
  34337. static set BaseUrl(value: string);
  34338. /**
  34339. * Enable/Disable Custom HTTP Request Headers globally.
  34340. * default = false
  34341. * @see CustomRequestHeaders
  34342. */
  34343. static UseCustomRequestHeaders: boolean;
  34344. /**
  34345. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34346. * i.e. when loading files, where the server/service expects an Authorization header
  34347. */
  34348. static CustomRequestHeaders: {
  34349. [key: string]: string;
  34350. };
  34351. /**
  34352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34353. */
  34354. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34355. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34356. /**
  34357. * Default behaviour for cors in the application.
  34358. * It can be a string if the expected behavior is identical in the entire app.
  34359. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34360. */
  34361. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34362. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34363. /**
  34364. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34365. * @ignorenaming
  34366. */
  34367. static get UseFallbackTexture(): boolean;
  34368. static set UseFallbackTexture(value: boolean);
  34369. /**
  34370. * Use this object to register external classes like custom textures or material
  34371. * to allow the laoders to instantiate them
  34372. */
  34373. static get RegisteredExternalClasses(): {
  34374. [key: string]: Object;
  34375. };
  34376. static set RegisteredExternalClasses(classes: {
  34377. [key: string]: Object;
  34378. });
  34379. /**
  34380. * Texture content used if a texture cannot loaded
  34381. * @ignorenaming
  34382. */
  34383. static get fallbackTexture(): string;
  34384. static set fallbackTexture(value: string);
  34385. /**
  34386. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34387. * @param u defines the coordinate on X axis
  34388. * @param v defines the coordinate on Y axis
  34389. * @param width defines the width of the source data
  34390. * @param height defines the height of the source data
  34391. * @param pixels defines the source byte array
  34392. * @param color defines the output color
  34393. */
  34394. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34395. /**
  34396. * Interpolates between a and b via alpha
  34397. * @param a The lower value (returned when alpha = 0)
  34398. * @param b The upper value (returned when alpha = 1)
  34399. * @param alpha The interpolation-factor
  34400. * @return The mixed value
  34401. */
  34402. static Mix(a: number, b: number, alpha: number): number;
  34403. /**
  34404. * Tries to instantiate a new object from a given class name
  34405. * @param className defines the class name to instantiate
  34406. * @returns the new object or null if the system was not able to do the instantiation
  34407. */
  34408. static Instantiate(className: string): any;
  34409. /**
  34410. * Provides a slice function that will work even on IE
  34411. * @param data defines the array to slice
  34412. * @param start defines the start of the data (optional)
  34413. * @param end defines the end of the data (optional)
  34414. * @returns the new sliced array
  34415. */
  34416. static Slice<T>(data: T, start?: number, end?: number): T;
  34417. /**
  34418. * Polyfill for setImmediate
  34419. * @param action defines the action to execute after the current execution block
  34420. */
  34421. static SetImmediate(action: () => void): void;
  34422. /**
  34423. * Function indicating if a number is an exponent of 2
  34424. * @param value defines the value to test
  34425. * @returns true if the value is an exponent of 2
  34426. */
  34427. static IsExponentOfTwo(value: number): boolean;
  34428. private static _tmpFloatArray;
  34429. /**
  34430. * Returns the nearest 32-bit single precision float representation of a Number
  34431. * @param value A Number. If the parameter is of a different type, it will get converted
  34432. * to a number or to NaN if it cannot be converted
  34433. * @returns number
  34434. */
  34435. static FloatRound(value: number): number;
  34436. /**
  34437. * Extracts the filename from a path
  34438. * @param path defines the path to use
  34439. * @returns the filename
  34440. */
  34441. static GetFilename(path: string): string;
  34442. /**
  34443. * Extracts the "folder" part of a path (everything before the filename).
  34444. * @param uri The URI to extract the info from
  34445. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34446. * @returns The "folder" part of the path
  34447. */
  34448. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34449. /**
  34450. * Extracts text content from a DOM element hierarchy
  34451. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34452. */
  34453. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34454. /**
  34455. * Convert an angle in radians to degrees
  34456. * @param angle defines the angle to convert
  34457. * @returns the angle in degrees
  34458. */
  34459. static ToDegrees(angle: number): number;
  34460. /**
  34461. * Convert an angle in degrees to radians
  34462. * @param angle defines the angle to convert
  34463. * @returns the angle in radians
  34464. */
  34465. static ToRadians(angle: number): number;
  34466. /**
  34467. * Returns an array if obj is not an array
  34468. * @param obj defines the object to evaluate as an array
  34469. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34470. * @returns either obj directly if obj is an array or a new array containing obj
  34471. */
  34472. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34473. /**
  34474. * Gets the pointer prefix to use
  34475. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34476. */
  34477. static GetPointerPrefix(): string;
  34478. /**
  34479. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34480. * @param url define the url we are trying
  34481. * @param element define the dom element where to configure the cors policy
  34482. */
  34483. static SetCorsBehavior(url: string | string[], element: {
  34484. crossOrigin: string | null;
  34485. }): void;
  34486. /**
  34487. * Removes unwanted characters from an url
  34488. * @param url defines the url to clean
  34489. * @returns the cleaned url
  34490. */
  34491. static CleanUrl(url: string): string;
  34492. /**
  34493. * Gets or sets a function used to pre-process url before using them to load assets
  34494. */
  34495. static get PreprocessUrl(): (url: string) => string;
  34496. static set PreprocessUrl(processor: (url: string) => string);
  34497. /**
  34498. * Loads an image as an HTMLImageElement.
  34499. * @param input url string, ArrayBuffer, or Blob to load
  34500. * @param onLoad callback called when the image successfully loads
  34501. * @param onError callback called when the image fails to load
  34502. * @param offlineProvider offline provider for caching
  34503. * @param mimeType optional mime type
  34504. * @returns the HTMLImageElement of the loaded image
  34505. */
  34506. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34507. /**
  34508. * Loads a file from a url
  34509. * @param url url string, ArrayBuffer, or Blob to load
  34510. * @param onSuccess callback called when the file successfully loads
  34511. * @param onProgress callback called while file is loading (if the server supports this mode)
  34512. * @param offlineProvider defines the offline provider for caching
  34513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34514. * @param onError callback called when the file fails to load
  34515. * @returns a file request object
  34516. */
  34517. 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;
  34518. /**
  34519. * Loads a file from a url
  34520. * @param url the file url to load
  34521. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34522. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34523. */
  34524. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34525. /**
  34526. * Load a script (identified by an url). When the url returns, the
  34527. * content of this file is added into a new script element, attached to the DOM (body element)
  34528. * @param scriptUrl defines the url of the script to laod
  34529. * @param onSuccess defines the callback called when the script is loaded
  34530. * @param onError defines the callback to call if an error occurs
  34531. * @param scriptId defines the id of the script element
  34532. */
  34533. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34534. /**
  34535. * Load an asynchronous script (identified by an url). When the url returns, the
  34536. * content of this file is added into a new script element, attached to the DOM (body element)
  34537. * @param scriptUrl defines the url of the script to laod
  34538. * @param scriptId defines the id of the script element
  34539. * @returns a promise request object
  34540. */
  34541. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34542. /**
  34543. * Loads a file from a blob
  34544. * @param fileToLoad defines the blob to use
  34545. * @param callback defines the callback to call when data is loaded
  34546. * @param progressCallback defines the callback to call during loading process
  34547. * @returns a file request object
  34548. */
  34549. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34550. /**
  34551. * Reads a file from a File object
  34552. * @param file defines the file to load
  34553. * @param onSuccess defines the callback to call when data is loaded
  34554. * @param onProgress defines the callback to call during loading process
  34555. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34556. * @param onError defines the callback to call when an error occurs
  34557. * @returns a file request object
  34558. */
  34559. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34560. /**
  34561. * Creates a data url from a given string content
  34562. * @param content defines the content to convert
  34563. * @returns the new data url link
  34564. */
  34565. static FileAsURL(content: string): string;
  34566. /**
  34567. * Format the given number to a specific decimal format
  34568. * @param value defines the number to format
  34569. * @param decimals defines the number of decimals to use
  34570. * @returns the formatted string
  34571. */
  34572. static Format(value: number, decimals?: number): string;
  34573. /**
  34574. * Tries to copy an object by duplicating every property
  34575. * @param source defines the source object
  34576. * @param destination defines the target object
  34577. * @param doNotCopyList defines a list of properties to avoid
  34578. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34579. */
  34580. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34581. /**
  34582. * Gets a boolean indicating if the given object has no own property
  34583. * @param obj defines the object to test
  34584. * @returns true if object has no own property
  34585. */
  34586. static IsEmpty(obj: any): boolean;
  34587. /**
  34588. * Function used to register events at window level
  34589. * @param windowElement defines the Window object to use
  34590. * @param events defines the events to register
  34591. */
  34592. static RegisterTopRootEvents(windowElement: Window, events: {
  34593. name: string;
  34594. handler: Nullable<(e: FocusEvent) => any>;
  34595. }[]): void;
  34596. /**
  34597. * Function used to unregister events from window level
  34598. * @param windowElement defines the Window object to use
  34599. * @param events defines the events to unregister
  34600. */
  34601. static UnregisterTopRootEvents(windowElement: Window, events: {
  34602. name: string;
  34603. handler: Nullable<(e: FocusEvent) => any>;
  34604. }[]): void;
  34605. /**
  34606. * @ignore
  34607. */
  34608. static _ScreenshotCanvas: HTMLCanvasElement;
  34609. /**
  34610. * Dumps the current bound framebuffer
  34611. * @param width defines the rendering width
  34612. * @param height defines the rendering height
  34613. * @param engine defines the hosting engine
  34614. * @param successCallback defines the callback triggered once the data are available
  34615. * @param mimeType defines the mime type of the result
  34616. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34617. */
  34618. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34619. /**
  34620. * Converts the canvas data to blob.
  34621. * This acts as a polyfill for browsers not supporting the to blob function.
  34622. * @param canvas Defines the canvas to extract the data from
  34623. * @param successCallback Defines the callback triggered once the data are available
  34624. * @param mimeType Defines the mime type of the result
  34625. */
  34626. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34627. /**
  34628. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34629. * @param successCallback defines the callback triggered once the data are available
  34630. * @param mimeType defines the mime type of the result
  34631. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34632. */
  34633. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34634. /**
  34635. * Downloads a blob in the browser
  34636. * @param blob defines the blob to download
  34637. * @param fileName defines the name of the downloaded file
  34638. */
  34639. static Download(blob: Blob, fileName: string): void;
  34640. /**
  34641. * Captures a screenshot of the current rendering
  34642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34643. * @param engine defines the rendering engine
  34644. * @param camera defines the source camera
  34645. * @param size This parameter can be set to a single number or to an object with the
  34646. * following (optional) properties: precision, width, height. If a single number is passed,
  34647. * it will be used for both width and height. If an object is passed, the screenshot size
  34648. * will be derived from the parameters. The precision property is a multiplier allowing
  34649. * rendering at a higher or lower resolution
  34650. * @param successCallback defines the callback receives a single parameter which contains the
  34651. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34652. * src parameter of an <img> to display it
  34653. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34654. * Check your browser for supported MIME types
  34655. */
  34656. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34657. /**
  34658. * Captures a screenshot of the current rendering
  34659. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34660. * @param engine defines the rendering engine
  34661. * @param camera defines the source camera
  34662. * @param size This parameter can be set to a single number or to an object with the
  34663. * following (optional) properties: precision, width, height. If a single number is passed,
  34664. * it will be used for both width and height. If an object is passed, the screenshot size
  34665. * will be derived from the parameters. The precision property is a multiplier allowing
  34666. * rendering at a higher or lower resolution
  34667. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34668. * Check your browser for supported MIME types
  34669. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34670. * to the src parameter of an <img> to display it
  34671. */
  34672. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34673. /**
  34674. * Generates an image screenshot from the specified camera.
  34675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34676. * @param engine The engine to use for rendering
  34677. * @param camera The camera to use for rendering
  34678. * @param size This parameter can be set to a single number or to an object with the
  34679. * following (optional) properties: precision, width, height. If a single number is passed,
  34680. * it will be used for both width and height. If an object is passed, the screenshot size
  34681. * will be derived from the parameters. The precision property is a multiplier allowing
  34682. * rendering at a higher or lower resolution
  34683. * @param successCallback The callback receives a single parameter which contains the
  34684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34685. * src parameter of an <img> to display it
  34686. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34687. * Check your browser for supported MIME types
  34688. * @param samples Texture samples (default: 1)
  34689. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34690. * @param fileName A name for for the downloaded file.
  34691. */
  34692. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34693. /**
  34694. * Generates an image screenshot from the specified camera.
  34695. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34696. * @param engine The engine to use for rendering
  34697. * @param camera The camera to use for rendering
  34698. * @param size This parameter can be set to a single number or to an object with the
  34699. * following (optional) properties: precision, width, height. If a single number is passed,
  34700. * it will be used for both width and height. If an object is passed, the screenshot size
  34701. * will be derived from the parameters. The precision property is a multiplier allowing
  34702. * rendering at a higher or lower resolution
  34703. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34704. * Check your browser for supported MIME types
  34705. * @param samples Texture samples (default: 1)
  34706. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34707. * @param fileName A name for for the downloaded file.
  34708. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34709. * to the src parameter of an <img> to display it
  34710. */
  34711. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34712. /**
  34713. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34714. * Be aware Math.random() could cause collisions, but:
  34715. * "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"
  34716. * @returns a pseudo random id
  34717. */
  34718. static RandomId(): string;
  34719. /**
  34720. * Test if the given uri is a base64 string
  34721. * @param uri The uri to test
  34722. * @return True if the uri is a base64 string or false otherwise
  34723. */
  34724. static IsBase64(uri: string): boolean;
  34725. /**
  34726. * Decode the given base64 uri.
  34727. * @param uri The uri to decode
  34728. * @return The decoded base64 data.
  34729. */
  34730. static DecodeBase64(uri: string): ArrayBuffer;
  34731. /**
  34732. * Gets the absolute url.
  34733. * @param url the input url
  34734. * @return the absolute url
  34735. */
  34736. static GetAbsoluteUrl(url: string): string;
  34737. /**
  34738. * No log
  34739. */
  34740. static readonly NoneLogLevel: number;
  34741. /**
  34742. * Only message logs
  34743. */
  34744. static readonly MessageLogLevel: number;
  34745. /**
  34746. * Only warning logs
  34747. */
  34748. static readonly WarningLogLevel: number;
  34749. /**
  34750. * Only error logs
  34751. */
  34752. static readonly ErrorLogLevel: number;
  34753. /**
  34754. * All logs
  34755. */
  34756. static readonly AllLogLevel: number;
  34757. /**
  34758. * Gets a value indicating the number of loading errors
  34759. * @ignorenaming
  34760. */
  34761. static get errorsCount(): number;
  34762. /**
  34763. * Callback called when a new log is added
  34764. */
  34765. static OnNewCacheEntry: (entry: string) => void;
  34766. /**
  34767. * Log a message to the console
  34768. * @param message defines the message to log
  34769. */
  34770. static Log(message: string): void;
  34771. /**
  34772. * Write a warning message to the console
  34773. * @param message defines the message to log
  34774. */
  34775. static Warn(message: string): void;
  34776. /**
  34777. * Write an error message to the console
  34778. * @param message defines the message to log
  34779. */
  34780. static Error(message: string): void;
  34781. /**
  34782. * Gets current log cache (list of logs)
  34783. */
  34784. static get LogCache(): string;
  34785. /**
  34786. * Clears the log cache
  34787. */
  34788. static ClearLogCache(): void;
  34789. /**
  34790. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34791. */
  34792. static set LogLevels(level: number);
  34793. /**
  34794. * Checks if the window object exists
  34795. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34796. */
  34797. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34798. /**
  34799. * No performance log
  34800. */
  34801. static readonly PerformanceNoneLogLevel: number;
  34802. /**
  34803. * Use user marks to log performance
  34804. */
  34805. static readonly PerformanceUserMarkLogLevel: number;
  34806. /**
  34807. * Log performance to the console
  34808. */
  34809. static readonly PerformanceConsoleLogLevel: number;
  34810. private static _performance;
  34811. /**
  34812. * Sets the current performance log level
  34813. */
  34814. static set PerformanceLogLevel(level: number);
  34815. private static _StartPerformanceCounterDisabled;
  34816. private static _EndPerformanceCounterDisabled;
  34817. private static _StartUserMark;
  34818. private static _EndUserMark;
  34819. private static _StartPerformanceConsole;
  34820. private static _EndPerformanceConsole;
  34821. /**
  34822. * Starts a performance counter
  34823. */
  34824. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34825. /**
  34826. * Ends a specific performance coutner
  34827. */
  34828. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34829. /**
  34830. * Gets either window.performance.now() if supported or Date.now() else
  34831. */
  34832. static get Now(): number;
  34833. /**
  34834. * This method will return the name of the class used to create the instance of the given object.
  34835. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34836. * @param object the object to get the class name from
  34837. * @param isType defines if the object is actually a type
  34838. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34839. */
  34840. static GetClassName(object: any, isType?: boolean): string;
  34841. /**
  34842. * Gets the first element of an array satisfying a given predicate
  34843. * @param array defines the array to browse
  34844. * @param predicate defines the predicate to use
  34845. * @returns null if not found or the element
  34846. */
  34847. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34848. /**
  34849. * This method will return the name of the full name of the class, including its owning module (if any).
  34850. * 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).
  34851. * @param object the object to get the class name from
  34852. * @param isType defines if the object is actually a type
  34853. * @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.
  34854. * @ignorenaming
  34855. */
  34856. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34857. /**
  34858. * Returns a promise that resolves after the given amount of time.
  34859. * @param delay Number of milliseconds to delay
  34860. * @returns Promise that resolves after the given amount of time
  34861. */
  34862. static DelayAsync(delay: number): Promise<void>;
  34863. /**
  34864. * Utility function to detect if the current user agent is Safari
  34865. * @returns whether or not the current user agent is safari
  34866. */
  34867. static IsSafari(): boolean;
  34868. }
  34869. /**
  34870. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34871. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34872. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34873. * @param name The name of the class, case should be preserved
  34874. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34875. */
  34876. export function className(name: string, module?: string): (target: Object) => void;
  34877. /**
  34878. * An implementation of a loop for asynchronous functions.
  34879. */
  34880. export class AsyncLoop {
  34881. /**
  34882. * Defines the number of iterations for the loop
  34883. */
  34884. iterations: number;
  34885. /**
  34886. * Defines the current index of the loop.
  34887. */
  34888. index: number;
  34889. private _done;
  34890. private _fn;
  34891. private _successCallback;
  34892. /**
  34893. * Constructor.
  34894. * @param iterations the number of iterations.
  34895. * @param func the function to run each iteration
  34896. * @param successCallback the callback that will be called upon succesful execution
  34897. * @param offset starting offset.
  34898. */
  34899. constructor(
  34900. /**
  34901. * Defines the number of iterations for the loop
  34902. */
  34903. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34904. /**
  34905. * Execute the next iteration. Must be called after the last iteration was finished.
  34906. */
  34907. executeNext(): void;
  34908. /**
  34909. * Break the loop and run the success callback.
  34910. */
  34911. breakLoop(): void;
  34912. /**
  34913. * Create and run an async loop.
  34914. * @param iterations the number of iterations.
  34915. * @param fn the function to run each iteration
  34916. * @param successCallback the callback that will be called upon succesful execution
  34917. * @param offset starting offset.
  34918. * @returns the created async loop object
  34919. */
  34920. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34921. /**
  34922. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34923. * @param iterations total number of iterations
  34924. * @param syncedIterations number of synchronous iterations in each async iteration.
  34925. * @param fn the function to call each iteration.
  34926. * @param callback a success call back that will be called when iterating stops.
  34927. * @param breakFunction a break condition (optional)
  34928. * @param timeout timeout settings for the setTimeout function. default - 0.
  34929. * @returns the created async loop object
  34930. */
  34931. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /**
  34936. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34937. * The underlying implementation relies on an associative array to ensure the best performances.
  34938. * The value can be anything including 'null' but except 'undefined'
  34939. */
  34940. export class StringDictionary<T> {
  34941. /**
  34942. * This will clear this dictionary and copy the content from the 'source' one.
  34943. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34944. * @param source the dictionary to take the content from and copy to this dictionary
  34945. */
  34946. copyFrom(source: StringDictionary<T>): void;
  34947. /**
  34948. * Get a value based from its key
  34949. * @param key the given key to get the matching value from
  34950. * @return the value if found, otherwise undefined is returned
  34951. */
  34952. get(key: string): T | undefined;
  34953. /**
  34954. * Get a value from its key or add it if it doesn't exist.
  34955. * This method will ensure you that a given key/data will be present in the dictionary.
  34956. * @param key the given key to get the matching value from
  34957. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34958. * The factory will only be invoked if there's no data for the given key.
  34959. * @return the value corresponding to the key.
  34960. */
  34961. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34962. /**
  34963. * Get a value from its key if present in the dictionary otherwise add it
  34964. * @param key the key to get the value from
  34965. * @param val if there's no such key/value pair in the dictionary add it with this value
  34966. * @return the value corresponding to the key
  34967. */
  34968. getOrAdd(key: string, val: T): T;
  34969. /**
  34970. * Check if there's a given key in the dictionary
  34971. * @param key the key to check for
  34972. * @return true if the key is present, false otherwise
  34973. */
  34974. contains(key: string): boolean;
  34975. /**
  34976. * Add a new key and its corresponding value
  34977. * @param key the key to add
  34978. * @param value the value corresponding to the key
  34979. * @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
  34980. */
  34981. add(key: string, value: T): boolean;
  34982. /**
  34983. * Update a specific value associated to a key
  34984. * @param key defines the key to use
  34985. * @param value defines the value to store
  34986. * @returns true if the value was updated (or false if the key was not found)
  34987. */
  34988. set(key: string, value: T): boolean;
  34989. /**
  34990. * Get the element of the given key and remove it from the dictionary
  34991. * @param key defines the key to search
  34992. * @returns the value associated with the key or null if not found
  34993. */
  34994. getAndRemove(key: string): Nullable<T>;
  34995. /**
  34996. * Remove a key/value from the dictionary.
  34997. * @param key the key to remove
  34998. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34999. */
  35000. remove(key: string): boolean;
  35001. /**
  35002. * Clear the whole content of the dictionary
  35003. */
  35004. clear(): void;
  35005. /**
  35006. * Gets the current count
  35007. */
  35008. get count(): number;
  35009. /**
  35010. * Execute a callback on each key/val of the dictionary.
  35011. * Note that you can remove any element in this dictionary in the callback implementation
  35012. * @param callback the callback to execute on a given key/value pair
  35013. */
  35014. forEach(callback: (key: string, val: T) => void): void;
  35015. /**
  35016. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35017. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35018. * Note that you can remove any element in this dictionary in the callback implementation
  35019. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35020. * @returns the first item
  35021. */
  35022. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35023. private _count;
  35024. private _data;
  35025. }
  35026. }
  35027. declare module BABYLON {
  35028. /** @hidden */
  35029. export interface ICollisionCoordinator {
  35030. createCollider(): Collider;
  35031. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35032. init(scene: Scene): void;
  35033. }
  35034. /** @hidden */
  35035. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35036. private _scene;
  35037. private _scaledPosition;
  35038. private _scaledVelocity;
  35039. private _finalPosition;
  35040. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35041. createCollider(): Collider;
  35042. init(scene: Scene): void;
  35043. private _collideWithWorld;
  35044. }
  35045. }
  35046. declare module BABYLON {
  35047. /**
  35048. * Class used to manage all inputs for the scene.
  35049. */
  35050. export class InputManager {
  35051. /** The distance in pixel that you have to move to prevent some events */
  35052. static DragMovementThreshold: number;
  35053. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35054. static LongPressDelay: number;
  35055. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35056. static DoubleClickDelay: number;
  35057. /** If you need to check double click without raising a single click at first click, enable this flag */
  35058. static ExclusiveDoubleClickMode: boolean;
  35059. private _wheelEventName;
  35060. private _onPointerMove;
  35061. private _onPointerDown;
  35062. private _onPointerUp;
  35063. private _initClickEvent;
  35064. private _initActionManager;
  35065. private _delayedSimpleClick;
  35066. private _delayedSimpleClickTimeout;
  35067. private _previousDelayedSimpleClickTimeout;
  35068. private _meshPickProceed;
  35069. private _previousButtonPressed;
  35070. private _currentPickResult;
  35071. private _previousPickResult;
  35072. private _totalPointersPressed;
  35073. private _doubleClickOccured;
  35074. private _pointerOverMesh;
  35075. private _pickedDownMesh;
  35076. private _pickedUpMesh;
  35077. private _pointerX;
  35078. private _pointerY;
  35079. private _unTranslatedPointerX;
  35080. private _unTranslatedPointerY;
  35081. private _startingPointerPosition;
  35082. private _previousStartingPointerPosition;
  35083. private _startingPointerTime;
  35084. private _previousStartingPointerTime;
  35085. private _pointerCaptures;
  35086. private _onKeyDown;
  35087. private _onKeyUp;
  35088. private _onCanvasFocusObserver;
  35089. private _onCanvasBlurObserver;
  35090. private _scene;
  35091. /**
  35092. * Creates a new InputManager
  35093. * @param scene defines the hosting scene
  35094. */
  35095. constructor(scene: Scene);
  35096. /**
  35097. * Gets the mesh that is currently under the pointer
  35098. */
  35099. get meshUnderPointer(): Nullable<AbstractMesh>;
  35100. /**
  35101. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35102. */
  35103. get unTranslatedPointer(): Vector2;
  35104. /**
  35105. * Gets or sets the current on-screen X position of the pointer
  35106. */
  35107. get pointerX(): number;
  35108. set pointerX(value: number);
  35109. /**
  35110. * Gets or sets the current on-screen Y position of the pointer
  35111. */
  35112. get pointerY(): number;
  35113. set pointerY(value: number);
  35114. private _updatePointerPosition;
  35115. private _processPointerMove;
  35116. private _setRayOnPointerInfo;
  35117. private _checkPrePointerObservable;
  35118. /**
  35119. * Use this method to simulate a pointer move on a mesh
  35120. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35121. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35122. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35123. */
  35124. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35125. /**
  35126. * Use this method to simulate a pointer down on a mesh
  35127. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35128. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35129. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35130. */
  35131. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35132. private _processPointerDown;
  35133. /** @hidden */
  35134. _isPointerSwiping(): boolean;
  35135. /**
  35136. * Use this method to simulate a pointer up on a mesh
  35137. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35138. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35139. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35140. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35141. */
  35142. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35143. private _processPointerUp;
  35144. /**
  35145. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35146. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35147. * @returns true if the pointer was captured
  35148. */
  35149. isPointerCaptured(pointerId?: number): boolean;
  35150. /**
  35151. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35152. * @param attachUp defines if you want to attach events to pointerup
  35153. * @param attachDown defines if you want to attach events to pointerdown
  35154. * @param attachMove defines if you want to attach events to pointermove
  35155. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35156. */
  35157. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35158. /**
  35159. * Detaches all event handlers
  35160. */
  35161. detachControl(): void;
  35162. /**
  35163. * Force the value of meshUnderPointer
  35164. * @param mesh defines the mesh to use
  35165. */
  35166. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35167. /**
  35168. * Gets the mesh under the pointer
  35169. * @returns a Mesh or null if no mesh is under the pointer
  35170. */
  35171. getPointerOverMesh(): Nullable<AbstractMesh>;
  35172. }
  35173. }
  35174. declare module BABYLON {
  35175. /**
  35176. * Helper class used to generate session unique ID
  35177. */
  35178. export class UniqueIdGenerator {
  35179. private static _UniqueIdCounter;
  35180. /**
  35181. * Gets an unique (relatively to the current scene) Id
  35182. */
  35183. static get UniqueId(): number;
  35184. }
  35185. }
  35186. declare module BABYLON {
  35187. /**
  35188. * This class defines the direct association between an animation and a target
  35189. */
  35190. export class TargetedAnimation {
  35191. /**
  35192. * Animation to perform
  35193. */
  35194. animation: Animation;
  35195. /**
  35196. * Target to animate
  35197. */
  35198. target: any;
  35199. /**
  35200. * Serialize the object
  35201. * @returns the JSON object representing the current entity
  35202. */
  35203. serialize(): any;
  35204. }
  35205. /**
  35206. * Use this class to create coordinated animations on multiple targets
  35207. */
  35208. export class AnimationGroup implements IDisposable {
  35209. /** The name of the animation group */
  35210. name: string;
  35211. private _scene;
  35212. private _targetedAnimations;
  35213. private _animatables;
  35214. private _from;
  35215. private _to;
  35216. private _isStarted;
  35217. private _isPaused;
  35218. private _speedRatio;
  35219. private _loopAnimation;
  35220. private _isAdditive;
  35221. /**
  35222. * Gets or sets the unique id of the node
  35223. */
  35224. uniqueId: number;
  35225. /**
  35226. * This observable will notify when one animation have ended
  35227. */
  35228. onAnimationEndObservable: Observable<TargetedAnimation>;
  35229. /**
  35230. * Observer raised when one animation loops
  35231. */
  35232. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35233. /**
  35234. * Observer raised when all animations have looped
  35235. */
  35236. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35237. /**
  35238. * This observable will notify when all animations have ended.
  35239. */
  35240. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35241. /**
  35242. * This observable will notify when all animations have paused.
  35243. */
  35244. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35245. /**
  35246. * This observable will notify when all animations are playing.
  35247. */
  35248. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35249. /**
  35250. * Gets the first frame
  35251. */
  35252. get from(): number;
  35253. /**
  35254. * Gets the last frame
  35255. */
  35256. get to(): number;
  35257. /**
  35258. * Define if the animations are started
  35259. */
  35260. get isStarted(): boolean;
  35261. /**
  35262. * Gets a value indicating that the current group is playing
  35263. */
  35264. get isPlaying(): boolean;
  35265. /**
  35266. * Gets or sets the speed ratio to use for all animations
  35267. */
  35268. get speedRatio(): number;
  35269. /**
  35270. * Gets or sets the speed ratio to use for all animations
  35271. */
  35272. set speedRatio(value: number);
  35273. /**
  35274. * Gets or sets if all animations should loop or not
  35275. */
  35276. get loopAnimation(): boolean;
  35277. set loopAnimation(value: boolean);
  35278. /**
  35279. * Gets or sets if all animations should be evaluated additively
  35280. */
  35281. get isAdditive(): boolean;
  35282. set isAdditive(value: boolean);
  35283. /**
  35284. * Gets the targeted animations for this animation group
  35285. */
  35286. get targetedAnimations(): Array<TargetedAnimation>;
  35287. /**
  35288. * returning the list of animatables controlled by this animation group.
  35289. */
  35290. get animatables(): Array<Animatable>;
  35291. /**
  35292. * Instantiates a new Animation Group.
  35293. * This helps managing several animations at once.
  35294. * @see http://doc.babylonjs.com/how_to/group
  35295. * @param name Defines the name of the group
  35296. * @param scene Defines the scene the group belongs to
  35297. */
  35298. constructor(
  35299. /** The name of the animation group */
  35300. name: string, scene?: Nullable<Scene>);
  35301. /**
  35302. * Add an animation (with its target) in the group
  35303. * @param animation defines the animation we want to add
  35304. * @param target defines the target of the animation
  35305. * @returns the TargetedAnimation object
  35306. */
  35307. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35308. /**
  35309. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35310. * It can add constant keys at begin or end
  35311. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35312. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35313. * @returns the animation group
  35314. */
  35315. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35316. private _animationLoopCount;
  35317. private _animationLoopFlags;
  35318. private _processLoop;
  35319. /**
  35320. * Start all animations on given targets
  35321. * @param loop defines if animations must loop
  35322. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35323. * @param from defines the from key (optional)
  35324. * @param to defines the to key (optional)
  35325. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35326. * @returns the current animation group
  35327. */
  35328. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35329. /**
  35330. * Pause all animations
  35331. * @returns the animation group
  35332. */
  35333. pause(): AnimationGroup;
  35334. /**
  35335. * Play all animations to initial state
  35336. * This function will start() the animations if they were not started or will restart() them if they were paused
  35337. * @param loop defines if animations must loop
  35338. * @returns the animation group
  35339. */
  35340. play(loop?: boolean): AnimationGroup;
  35341. /**
  35342. * Reset all animations to initial state
  35343. * @returns the animation group
  35344. */
  35345. reset(): AnimationGroup;
  35346. /**
  35347. * Restart animations from key 0
  35348. * @returns the animation group
  35349. */
  35350. restart(): AnimationGroup;
  35351. /**
  35352. * Stop all animations
  35353. * @returns the animation group
  35354. */
  35355. stop(): AnimationGroup;
  35356. /**
  35357. * Set animation weight for all animatables
  35358. * @param weight defines the weight to use
  35359. * @return the animationGroup
  35360. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35361. */
  35362. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35363. /**
  35364. * Synchronize and normalize all animatables with a source animatable
  35365. * @param root defines the root animatable to synchronize with
  35366. * @return the animationGroup
  35367. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35368. */
  35369. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35370. /**
  35371. * Goes to a specific frame in this animation group
  35372. * @param frame the frame number to go to
  35373. * @return the animationGroup
  35374. */
  35375. goToFrame(frame: number): AnimationGroup;
  35376. /**
  35377. * Dispose all associated resources
  35378. */
  35379. dispose(): void;
  35380. private _checkAnimationGroupEnded;
  35381. /**
  35382. * Clone the current animation group and returns a copy
  35383. * @param newName defines the name of the new group
  35384. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35385. * @returns the new aniamtion group
  35386. */
  35387. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35388. /**
  35389. * Serializes the animationGroup to an object
  35390. * @returns Serialized object
  35391. */
  35392. serialize(): any;
  35393. /**
  35394. * Returns a new AnimationGroup object parsed from the source provided.
  35395. * @param parsedAnimationGroup defines the source
  35396. * @param scene defines the scene that will receive the animationGroup
  35397. * @returns a new AnimationGroup
  35398. */
  35399. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35400. /**
  35401. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35402. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35403. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35404. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35405. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35406. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35407. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35408. */
  35409. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35410. /**
  35411. * Returns the string "AnimationGroup"
  35412. * @returns "AnimationGroup"
  35413. */
  35414. getClassName(): string;
  35415. /**
  35416. * Creates a detailled string about the object
  35417. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35418. * @returns a string representing the object
  35419. */
  35420. toString(fullDetails?: boolean): string;
  35421. }
  35422. }
  35423. declare module BABYLON {
  35424. /**
  35425. * Define an interface for all classes that will hold resources
  35426. */
  35427. export interface IDisposable {
  35428. /**
  35429. * Releases all held resources
  35430. */
  35431. dispose(): void;
  35432. }
  35433. /** Interface defining initialization parameters for Scene class */
  35434. export interface SceneOptions {
  35435. /**
  35436. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35437. * It will improve performance when the number of geometries becomes important.
  35438. */
  35439. useGeometryUniqueIdsMap?: boolean;
  35440. /**
  35441. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35442. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35443. */
  35444. useMaterialMeshMap?: boolean;
  35445. /**
  35446. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35447. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35448. */
  35449. useClonedMeshMap?: boolean;
  35450. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35451. virtual?: boolean;
  35452. }
  35453. /**
  35454. * Represents a scene to be rendered by the engine.
  35455. * @see http://doc.babylonjs.com/features/scene
  35456. */
  35457. export class Scene extends AbstractScene implements IAnimatable {
  35458. /** The fog is deactivated */
  35459. static readonly FOGMODE_NONE: number;
  35460. /** The fog density is following an exponential function */
  35461. static readonly FOGMODE_EXP: number;
  35462. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35463. static readonly FOGMODE_EXP2: number;
  35464. /** The fog density is following a linear function. */
  35465. static readonly FOGMODE_LINEAR: number;
  35466. /**
  35467. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35469. */
  35470. static MinDeltaTime: number;
  35471. /**
  35472. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35474. */
  35475. static MaxDeltaTime: number;
  35476. /**
  35477. * Factory used to create the default material.
  35478. * @param name The name of the material to create
  35479. * @param scene The scene to create the material for
  35480. * @returns The default material
  35481. */
  35482. static DefaultMaterialFactory(scene: Scene): Material;
  35483. /**
  35484. * Factory used to create the a collision coordinator.
  35485. * @returns The collision coordinator
  35486. */
  35487. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35488. /** @hidden */
  35489. _inputManager: InputManager;
  35490. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35491. cameraToUseForPointers: Nullable<Camera>;
  35492. /** @hidden */
  35493. readonly _isScene: boolean;
  35494. /** @hidden */
  35495. _blockEntityCollection: boolean;
  35496. /**
  35497. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35498. */
  35499. autoClear: boolean;
  35500. /**
  35501. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35502. */
  35503. autoClearDepthAndStencil: boolean;
  35504. /**
  35505. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35506. */
  35507. clearColor: Color4;
  35508. /**
  35509. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35510. */
  35511. ambientColor: Color3;
  35512. /**
  35513. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35514. * It should only be one of the following (if not the default embedded one):
  35515. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35516. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35517. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35518. * The material properties need to be setup according to the type of texture in use.
  35519. */
  35520. environmentBRDFTexture: BaseTexture;
  35521. /** @hidden */
  35522. protected _environmentTexture: Nullable<BaseTexture>;
  35523. /**
  35524. * Texture used in all pbr material as the reflection texture.
  35525. * As in the majority of the scene they are the same (exception for multi room and so on),
  35526. * this is easier to reference from here than from all the materials.
  35527. */
  35528. get environmentTexture(): Nullable<BaseTexture>;
  35529. /**
  35530. * Texture used in all pbr material as the reflection texture.
  35531. * As in the majority of the scene they are the same (exception for multi room and so on),
  35532. * this is easier to set here than in all the materials.
  35533. */
  35534. set environmentTexture(value: Nullable<BaseTexture>);
  35535. /** @hidden */
  35536. protected _environmentIntensity: number;
  35537. /**
  35538. * Intensity of the environment in all pbr material.
  35539. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35540. * As in the majority of the scene they are the same (exception for multi room and so on),
  35541. * this is easier to reference from here than from all the materials.
  35542. */
  35543. get environmentIntensity(): number;
  35544. /**
  35545. * Intensity of the environment in all pbr material.
  35546. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35547. * As in the majority of the scene they are the same (exception for multi room and so on),
  35548. * this is easier to set here than in all the materials.
  35549. */
  35550. set environmentIntensity(value: number);
  35551. /** @hidden */
  35552. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35553. /**
  35554. * Default image processing configuration used either in the rendering
  35555. * Forward main pass or through the imageProcessingPostProcess if present.
  35556. * As in the majority of the scene they are the same (exception for multi camera),
  35557. * this is easier to reference from here than from all the materials and post process.
  35558. *
  35559. * No setter as we it is a shared configuration, you can set the values instead.
  35560. */
  35561. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35562. private _forceWireframe;
  35563. /**
  35564. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35565. */
  35566. set forceWireframe(value: boolean);
  35567. get forceWireframe(): boolean;
  35568. private _skipFrustumClipping;
  35569. /**
  35570. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35571. */
  35572. set skipFrustumClipping(value: boolean);
  35573. get skipFrustumClipping(): boolean;
  35574. private _forcePointsCloud;
  35575. /**
  35576. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35577. */
  35578. set forcePointsCloud(value: boolean);
  35579. get forcePointsCloud(): boolean;
  35580. /**
  35581. * Gets or sets the active clipplane 1
  35582. */
  35583. clipPlane: Nullable<Plane>;
  35584. /**
  35585. * Gets or sets the active clipplane 2
  35586. */
  35587. clipPlane2: Nullable<Plane>;
  35588. /**
  35589. * Gets or sets the active clipplane 3
  35590. */
  35591. clipPlane3: Nullable<Plane>;
  35592. /**
  35593. * Gets or sets the active clipplane 4
  35594. */
  35595. clipPlane4: Nullable<Plane>;
  35596. /**
  35597. * Gets or sets the active clipplane 5
  35598. */
  35599. clipPlane5: Nullable<Plane>;
  35600. /**
  35601. * Gets or sets the active clipplane 6
  35602. */
  35603. clipPlane6: Nullable<Plane>;
  35604. /**
  35605. * Gets or sets a boolean indicating if animations are enabled
  35606. */
  35607. animationsEnabled: boolean;
  35608. private _animationPropertiesOverride;
  35609. /**
  35610. * Gets or sets the animation properties override
  35611. */
  35612. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35613. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35614. /**
  35615. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35616. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35617. */
  35618. useConstantAnimationDeltaTime: boolean;
  35619. /**
  35620. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35621. * Please note that it requires to run a ray cast through the scene on every frame
  35622. */
  35623. constantlyUpdateMeshUnderPointer: boolean;
  35624. /**
  35625. * Defines the HTML cursor to use when hovering over interactive elements
  35626. */
  35627. hoverCursor: string;
  35628. /**
  35629. * Defines the HTML default cursor to use (empty by default)
  35630. */
  35631. defaultCursor: string;
  35632. /**
  35633. * Defines whether cursors are handled by the scene.
  35634. */
  35635. doNotHandleCursors: boolean;
  35636. /**
  35637. * This is used to call preventDefault() on pointer down
  35638. * in order to block unwanted artifacts like system double clicks
  35639. */
  35640. preventDefaultOnPointerDown: boolean;
  35641. /**
  35642. * This is used to call preventDefault() on pointer up
  35643. * in order to block unwanted artifacts like system double clicks
  35644. */
  35645. preventDefaultOnPointerUp: boolean;
  35646. /**
  35647. * Gets or sets user defined metadata
  35648. */
  35649. metadata: any;
  35650. /**
  35651. * For internal use only. Please do not use.
  35652. */
  35653. reservedDataStore: any;
  35654. /**
  35655. * Gets the name of the plugin used to load this scene (null by default)
  35656. */
  35657. loadingPluginName: string;
  35658. /**
  35659. * Use this array to add regular expressions used to disable offline support for specific urls
  35660. */
  35661. disableOfflineSupportExceptionRules: RegExp[];
  35662. /**
  35663. * An event triggered when the scene is disposed.
  35664. */
  35665. onDisposeObservable: Observable<Scene>;
  35666. private _onDisposeObserver;
  35667. /** Sets a function to be executed when this scene is disposed. */
  35668. set onDispose(callback: () => void);
  35669. /**
  35670. * An event triggered before rendering the scene (right after animations and physics)
  35671. */
  35672. onBeforeRenderObservable: Observable<Scene>;
  35673. private _onBeforeRenderObserver;
  35674. /** Sets a function to be executed before rendering this scene */
  35675. set beforeRender(callback: Nullable<() => void>);
  35676. /**
  35677. * An event triggered after rendering the scene
  35678. */
  35679. onAfterRenderObservable: Observable<Scene>;
  35680. /**
  35681. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35682. */
  35683. onAfterRenderCameraObservable: Observable<Camera>;
  35684. private _onAfterRenderObserver;
  35685. /** Sets a function to be executed after rendering this scene */
  35686. set afterRender(callback: Nullable<() => void>);
  35687. /**
  35688. * An event triggered before animating the scene
  35689. */
  35690. onBeforeAnimationsObservable: Observable<Scene>;
  35691. /**
  35692. * An event triggered after animations processing
  35693. */
  35694. onAfterAnimationsObservable: Observable<Scene>;
  35695. /**
  35696. * An event triggered before draw calls are ready to be sent
  35697. */
  35698. onBeforeDrawPhaseObservable: Observable<Scene>;
  35699. /**
  35700. * An event triggered after draw calls have been sent
  35701. */
  35702. onAfterDrawPhaseObservable: Observable<Scene>;
  35703. /**
  35704. * An event triggered when the scene is ready
  35705. */
  35706. onReadyObservable: Observable<Scene>;
  35707. /**
  35708. * An event triggered before rendering a camera
  35709. */
  35710. onBeforeCameraRenderObservable: Observable<Camera>;
  35711. private _onBeforeCameraRenderObserver;
  35712. /** Sets a function to be executed before rendering a camera*/
  35713. set beforeCameraRender(callback: () => void);
  35714. /**
  35715. * An event triggered after rendering a camera
  35716. */
  35717. onAfterCameraRenderObservable: Observable<Camera>;
  35718. private _onAfterCameraRenderObserver;
  35719. /** Sets a function to be executed after rendering a camera*/
  35720. set afterCameraRender(callback: () => void);
  35721. /**
  35722. * An event triggered when active meshes evaluation is about to start
  35723. */
  35724. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35725. /**
  35726. * An event triggered when active meshes evaluation is done
  35727. */
  35728. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35729. /**
  35730. * An event triggered when particles rendering is about to start
  35731. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35732. */
  35733. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35734. /**
  35735. * An event triggered when particles rendering is done
  35736. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35737. */
  35738. onAfterParticlesRenderingObservable: Observable<Scene>;
  35739. /**
  35740. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35741. */
  35742. onDataLoadedObservable: Observable<Scene>;
  35743. /**
  35744. * An event triggered when a camera is created
  35745. */
  35746. onNewCameraAddedObservable: Observable<Camera>;
  35747. /**
  35748. * An event triggered when a camera is removed
  35749. */
  35750. onCameraRemovedObservable: Observable<Camera>;
  35751. /**
  35752. * An event triggered when a light is created
  35753. */
  35754. onNewLightAddedObservable: Observable<Light>;
  35755. /**
  35756. * An event triggered when a light is removed
  35757. */
  35758. onLightRemovedObservable: Observable<Light>;
  35759. /**
  35760. * An event triggered when a geometry is created
  35761. */
  35762. onNewGeometryAddedObservable: Observable<Geometry>;
  35763. /**
  35764. * An event triggered when a geometry is removed
  35765. */
  35766. onGeometryRemovedObservable: Observable<Geometry>;
  35767. /**
  35768. * An event triggered when a transform node is created
  35769. */
  35770. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35771. /**
  35772. * An event triggered when a transform node is removed
  35773. */
  35774. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35775. /**
  35776. * An event triggered when a mesh is created
  35777. */
  35778. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35779. /**
  35780. * An event triggered when a mesh is removed
  35781. */
  35782. onMeshRemovedObservable: Observable<AbstractMesh>;
  35783. /**
  35784. * An event triggered when a skeleton is created
  35785. */
  35786. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35787. /**
  35788. * An event triggered when a skeleton is removed
  35789. */
  35790. onSkeletonRemovedObservable: Observable<Skeleton>;
  35791. /**
  35792. * An event triggered when a material is created
  35793. */
  35794. onNewMaterialAddedObservable: Observable<Material>;
  35795. /**
  35796. * An event triggered when a material is removed
  35797. */
  35798. onMaterialRemovedObservable: Observable<Material>;
  35799. /**
  35800. * An event triggered when a texture is created
  35801. */
  35802. onNewTextureAddedObservable: Observable<BaseTexture>;
  35803. /**
  35804. * An event triggered when a texture is removed
  35805. */
  35806. onTextureRemovedObservable: Observable<BaseTexture>;
  35807. /**
  35808. * An event triggered when render targets are about to be rendered
  35809. * Can happen multiple times per frame.
  35810. */
  35811. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35812. /**
  35813. * An event triggered when render targets were rendered.
  35814. * Can happen multiple times per frame.
  35815. */
  35816. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35817. /**
  35818. * An event triggered before calculating deterministic simulation step
  35819. */
  35820. onBeforeStepObservable: Observable<Scene>;
  35821. /**
  35822. * An event triggered after calculating deterministic simulation step
  35823. */
  35824. onAfterStepObservable: Observable<Scene>;
  35825. /**
  35826. * An event triggered when the activeCamera property is updated
  35827. */
  35828. onActiveCameraChanged: Observable<Scene>;
  35829. /**
  35830. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35831. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35832. * 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)
  35833. */
  35834. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35835. /**
  35836. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35837. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35838. * 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)
  35839. */
  35840. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35841. /**
  35842. * This Observable will when a mesh has been imported into the scene.
  35843. */
  35844. onMeshImportedObservable: Observable<AbstractMesh>;
  35845. /**
  35846. * This Observable will when an animation file has been imported into the scene.
  35847. */
  35848. onAnimationFileImportedObservable: Observable<Scene>;
  35849. /**
  35850. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35851. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35852. */
  35853. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35854. /** @hidden */
  35855. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35856. /**
  35857. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35858. */
  35859. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35860. /**
  35861. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35862. */
  35863. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35864. /**
  35865. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35866. */
  35867. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35868. /** Callback called when a pointer move is detected */
  35869. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35870. /** Callback called when a pointer down is detected */
  35871. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35872. /** Callback called when a pointer up is detected */
  35873. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35874. /** Callback called when a pointer pick is detected */
  35875. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35876. /**
  35877. * 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).
  35878. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35879. */
  35880. onPrePointerObservable: Observable<PointerInfoPre>;
  35881. /**
  35882. * Observable event triggered each time an input event is received from the rendering canvas
  35883. */
  35884. onPointerObservable: Observable<PointerInfo>;
  35885. /**
  35886. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35887. */
  35888. get unTranslatedPointer(): Vector2;
  35889. /**
  35890. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35891. */
  35892. static get DragMovementThreshold(): number;
  35893. static set DragMovementThreshold(value: number);
  35894. /**
  35895. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35896. */
  35897. static get LongPressDelay(): number;
  35898. static set LongPressDelay(value: number);
  35899. /**
  35900. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35901. */
  35902. static get DoubleClickDelay(): number;
  35903. static set DoubleClickDelay(value: number);
  35904. /** If you need to check double click without raising a single click at first click, enable this flag */
  35905. static get ExclusiveDoubleClickMode(): boolean;
  35906. static set ExclusiveDoubleClickMode(value: boolean);
  35907. /** @hidden */
  35908. _mirroredCameraPosition: Nullable<Vector3>;
  35909. /**
  35910. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35911. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35912. */
  35913. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35914. /**
  35915. * Observable event triggered each time an keyboard event is received from the hosting window
  35916. */
  35917. onKeyboardObservable: Observable<KeyboardInfo>;
  35918. private _useRightHandedSystem;
  35919. /**
  35920. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35921. */
  35922. set useRightHandedSystem(value: boolean);
  35923. get useRightHandedSystem(): boolean;
  35924. private _timeAccumulator;
  35925. private _currentStepId;
  35926. private _currentInternalStep;
  35927. /**
  35928. * Sets the step Id used by deterministic lock step
  35929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35930. * @param newStepId defines the step Id
  35931. */
  35932. setStepId(newStepId: number): void;
  35933. /**
  35934. * Gets the step Id used by deterministic lock step
  35935. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35936. * @returns the step Id
  35937. */
  35938. getStepId(): number;
  35939. /**
  35940. * Gets the internal step used by deterministic lock step
  35941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35942. * @returns the internal step
  35943. */
  35944. getInternalStep(): number;
  35945. private _fogEnabled;
  35946. /**
  35947. * Gets or sets a boolean indicating if fog is enabled on this scene
  35948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35949. * (Default is true)
  35950. */
  35951. set fogEnabled(value: boolean);
  35952. get fogEnabled(): boolean;
  35953. private _fogMode;
  35954. /**
  35955. * Gets or sets the fog mode to use
  35956. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35957. * | mode | value |
  35958. * | --- | --- |
  35959. * | FOGMODE_NONE | 0 |
  35960. * | FOGMODE_EXP | 1 |
  35961. * | FOGMODE_EXP2 | 2 |
  35962. * | FOGMODE_LINEAR | 3 |
  35963. */
  35964. set fogMode(value: number);
  35965. get fogMode(): number;
  35966. /**
  35967. * Gets or sets the fog color to use
  35968. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35969. * (Default is Color3(0.2, 0.2, 0.3))
  35970. */
  35971. fogColor: Color3;
  35972. /**
  35973. * Gets or sets the fog density to use
  35974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35975. * (Default is 0.1)
  35976. */
  35977. fogDensity: number;
  35978. /**
  35979. * Gets or sets the fog start distance to use
  35980. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35981. * (Default is 0)
  35982. */
  35983. fogStart: number;
  35984. /**
  35985. * Gets or sets the fog end distance to use
  35986. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35987. * (Default is 1000)
  35988. */
  35989. fogEnd: number;
  35990. private _shadowsEnabled;
  35991. /**
  35992. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35993. */
  35994. set shadowsEnabled(value: boolean);
  35995. get shadowsEnabled(): boolean;
  35996. private _lightsEnabled;
  35997. /**
  35998. * Gets or sets a boolean indicating if lights are enabled on this scene
  35999. */
  36000. set lightsEnabled(value: boolean);
  36001. get lightsEnabled(): boolean;
  36002. /** All of the active cameras added to this scene. */
  36003. activeCameras: Camera[];
  36004. /** @hidden */
  36005. _activeCamera: Nullable<Camera>;
  36006. /** Gets or sets the current active camera */
  36007. get activeCamera(): Nullable<Camera>;
  36008. set activeCamera(value: Nullable<Camera>);
  36009. private _defaultMaterial;
  36010. /** The default material used on meshes when no material is affected */
  36011. get defaultMaterial(): Material;
  36012. /** The default material used on meshes when no material is affected */
  36013. set defaultMaterial(value: Material);
  36014. private _texturesEnabled;
  36015. /**
  36016. * Gets or sets a boolean indicating if textures are enabled on this scene
  36017. */
  36018. set texturesEnabled(value: boolean);
  36019. get texturesEnabled(): boolean;
  36020. /**
  36021. * Gets or sets a boolean indicating if particles are enabled on this scene
  36022. */
  36023. particlesEnabled: boolean;
  36024. /**
  36025. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36026. */
  36027. spritesEnabled: boolean;
  36028. private _skeletonsEnabled;
  36029. /**
  36030. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36031. */
  36032. set skeletonsEnabled(value: boolean);
  36033. get skeletonsEnabled(): boolean;
  36034. /**
  36035. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36036. */
  36037. lensFlaresEnabled: boolean;
  36038. /**
  36039. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36040. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36041. */
  36042. collisionsEnabled: boolean;
  36043. private _collisionCoordinator;
  36044. /** @hidden */
  36045. get collisionCoordinator(): ICollisionCoordinator;
  36046. /**
  36047. * Defines the gravity applied to this scene (used only for collisions)
  36048. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36049. */
  36050. gravity: Vector3;
  36051. /**
  36052. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36053. */
  36054. postProcessesEnabled: boolean;
  36055. /**
  36056. * The list of postprocesses added to the scene
  36057. */
  36058. postProcesses: PostProcess[];
  36059. /**
  36060. * Gets the current postprocess manager
  36061. */
  36062. postProcessManager: PostProcessManager;
  36063. /**
  36064. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36065. */
  36066. renderTargetsEnabled: boolean;
  36067. /**
  36068. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36069. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36070. */
  36071. dumpNextRenderTargets: boolean;
  36072. /**
  36073. * The list of user defined render targets added to the scene
  36074. */
  36075. customRenderTargets: RenderTargetTexture[];
  36076. /**
  36077. * Defines if texture loading must be delayed
  36078. * If true, textures will only be loaded when they need to be rendered
  36079. */
  36080. useDelayedTextureLoading: boolean;
  36081. /**
  36082. * Gets the list of meshes imported to the scene through SceneLoader
  36083. */
  36084. importedMeshesFiles: String[];
  36085. /**
  36086. * Gets or sets a boolean indicating if probes are enabled on this scene
  36087. */
  36088. probesEnabled: boolean;
  36089. /**
  36090. * Gets or sets the current offline provider to use to store scene data
  36091. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36092. */
  36093. offlineProvider: IOfflineProvider;
  36094. /**
  36095. * Gets or sets the action manager associated with the scene
  36096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36097. */
  36098. actionManager: AbstractActionManager;
  36099. private _meshesForIntersections;
  36100. /**
  36101. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36102. */
  36103. proceduralTexturesEnabled: boolean;
  36104. private _engine;
  36105. private _totalVertices;
  36106. /** @hidden */
  36107. _activeIndices: PerfCounter;
  36108. /** @hidden */
  36109. _activeParticles: PerfCounter;
  36110. /** @hidden */
  36111. _activeBones: PerfCounter;
  36112. private _animationRatio;
  36113. /** @hidden */
  36114. _animationTimeLast: number;
  36115. /** @hidden */
  36116. _animationTime: number;
  36117. /**
  36118. * Gets or sets a general scale for animation speed
  36119. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36120. */
  36121. animationTimeScale: number;
  36122. /** @hidden */
  36123. _cachedMaterial: Nullable<Material>;
  36124. /** @hidden */
  36125. _cachedEffect: Nullable<Effect>;
  36126. /** @hidden */
  36127. _cachedVisibility: Nullable<number>;
  36128. private _renderId;
  36129. private _frameId;
  36130. private _executeWhenReadyTimeoutId;
  36131. private _intermediateRendering;
  36132. private _viewUpdateFlag;
  36133. private _projectionUpdateFlag;
  36134. /** @hidden */
  36135. _toBeDisposed: Nullable<IDisposable>[];
  36136. private _activeRequests;
  36137. /** @hidden */
  36138. _pendingData: any[];
  36139. private _isDisposed;
  36140. /**
  36141. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36142. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36143. */
  36144. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36145. private _activeMeshes;
  36146. private _processedMaterials;
  36147. private _renderTargets;
  36148. /** @hidden */
  36149. _activeParticleSystems: SmartArray<IParticleSystem>;
  36150. private _activeSkeletons;
  36151. private _softwareSkinnedMeshes;
  36152. private _renderingManager;
  36153. /** @hidden */
  36154. _activeAnimatables: Animatable[];
  36155. private _transformMatrix;
  36156. private _sceneUbo;
  36157. /** @hidden */
  36158. _viewMatrix: Matrix;
  36159. private _projectionMatrix;
  36160. /** @hidden */
  36161. _forcedViewPosition: Nullable<Vector3>;
  36162. /** @hidden */
  36163. _frustumPlanes: Plane[];
  36164. /**
  36165. * Gets the list of frustum planes (built from the active camera)
  36166. */
  36167. get frustumPlanes(): Plane[];
  36168. /**
  36169. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36170. * This is useful if there are more lights that the maximum simulteanous authorized
  36171. */
  36172. requireLightSorting: boolean;
  36173. /** @hidden */
  36174. readonly useMaterialMeshMap: boolean;
  36175. /** @hidden */
  36176. readonly useClonedMeshMap: boolean;
  36177. private _externalData;
  36178. private _uid;
  36179. /**
  36180. * @hidden
  36181. * Backing store of defined scene components.
  36182. */
  36183. _components: ISceneComponent[];
  36184. /**
  36185. * @hidden
  36186. * Backing store of defined scene components.
  36187. */
  36188. _serializableComponents: ISceneSerializableComponent[];
  36189. /**
  36190. * List of components to register on the next registration step.
  36191. */
  36192. private _transientComponents;
  36193. /**
  36194. * Registers the transient components if needed.
  36195. */
  36196. private _registerTransientComponents;
  36197. /**
  36198. * @hidden
  36199. * Add a component to the scene.
  36200. * Note that the ccomponent could be registered on th next frame if this is called after
  36201. * the register component stage.
  36202. * @param component Defines the component to add to the scene
  36203. */
  36204. _addComponent(component: ISceneComponent): void;
  36205. /**
  36206. * @hidden
  36207. * Gets a component from the scene.
  36208. * @param name defines the name of the component to retrieve
  36209. * @returns the component or null if not present
  36210. */
  36211. _getComponent(name: string): Nullable<ISceneComponent>;
  36212. /**
  36213. * @hidden
  36214. * Defines the actions happening before camera updates.
  36215. */
  36216. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36217. /**
  36218. * @hidden
  36219. * Defines the actions happening before clear the canvas.
  36220. */
  36221. _beforeClearStage: Stage<SimpleStageAction>;
  36222. /**
  36223. * @hidden
  36224. * Defines the actions when collecting render targets for the frame.
  36225. */
  36226. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36227. /**
  36228. * @hidden
  36229. * Defines the actions happening for one camera in the frame.
  36230. */
  36231. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36232. /**
  36233. * @hidden
  36234. * Defines the actions happening during the per mesh ready checks.
  36235. */
  36236. _isReadyForMeshStage: Stage<MeshStageAction>;
  36237. /**
  36238. * @hidden
  36239. * Defines the actions happening before evaluate active mesh checks.
  36240. */
  36241. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36242. /**
  36243. * @hidden
  36244. * Defines the actions happening during the evaluate sub mesh checks.
  36245. */
  36246. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36247. /**
  36248. * @hidden
  36249. * Defines the actions happening during the active mesh stage.
  36250. */
  36251. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36252. /**
  36253. * @hidden
  36254. * Defines the actions happening during the per camera render target step.
  36255. */
  36256. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36257. /**
  36258. * @hidden
  36259. * Defines the actions happening just before the active camera is drawing.
  36260. */
  36261. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36262. /**
  36263. * @hidden
  36264. * Defines the actions happening just before a render target is drawing.
  36265. */
  36266. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36267. /**
  36268. * @hidden
  36269. * Defines the actions happening just before a rendering group is drawing.
  36270. */
  36271. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36272. /**
  36273. * @hidden
  36274. * Defines the actions happening just before a mesh is drawing.
  36275. */
  36276. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36277. /**
  36278. * @hidden
  36279. * Defines the actions happening just after a mesh has been drawn.
  36280. */
  36281. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36282. /**
  36283. * @hidden
  36284. * Defines the actions happening just after a rendering group has been drawn.
  36285. */
  36286. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36287. /**
  36288. * @hidden
  36289. * Defines the actions happening just after the active camera has been drawn.
  36290. */
  36291. _afterCameraDrawStage: Stage<CameraStageAction>;
  36292. /**
  36293. * @hidden
  36294. * Defines the actions happening just after a render target has been drawn.
  36295. */
  36296. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36297. /**
  36298. * @hidden
  36299. * Defines the actions happening just after rendering all cameras and computing intersections.
  36300. */
  36301. _afterRenderStage: Stage<SimpleStageAction>;
  36302. /**
  36303. * @hidden
  36304. * Defines the actions happening when a pointer move event happens.
  36305. */
  36306. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36307. /**
  36308. * @hidden
  36309. * Defines the actions happening when a pointer down event happens.
  36310. */
  36311. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36312. /**
  36313. * @hidden
  36314. * Defines the actions happening when a pointer up event happens.
  36315. */
  36316. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36317. /**
  36318. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36319. */
  36320. private geometriesByUniqueId;
  36321. /**
  36322. * Creates a new Scene
  36323. * @param engine defines the engine to use to render this scene
  36324. * @param options defines the scene options
  36325. */
  36326. constructor(engine: Engine, options?: SceneOptions);
  36327. /**
  36328. * Gets a string idenfifying the name of the class
  36329. * @returns "Scene" string
  36330. */
  36331. getClassName(): string;
  36332. private _defaultMeshCandidates;
  36333. /**
  36334. * @hidden
  36335. */
  36336. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36337. private _defaultSubMeshCandidates;
  36338. /**
  36339. * @hidden
  36340. */
  36341. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36342. /**
  36343. * Sets the default candidate providers for the scene.
  36344. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36345. * and getCollidingSubMeshCandidates to their default function
  36346. */
  36347. setDefaultCandidateProviders(): void;
  36348. /**
  36349. * Gets the mesh that is currently under the pointer
  36350. */
  36351. get meshUnderPointer(): Nullable<AbstractMesh>;
  36352. /**
  36353. * Gets or sets the current on-screen X position of the pointer
  36354. */
  36355. get pointerX(): number;
  36356. set pointerX(value: number);
  36357. /**
  36358. * Gets or sets the current on-screen Y position of the pointer
  36359. */
  36360. get pointerY(): number;
  36361. set pointerY(value: number);
  36362. /**
  36363. * Gets the cached material (ie. the latest rendered one)
  36364. * @returns the cached material
  36365. */
  36366. getCachedMaterial(): Nullable<Material>;
  36367. /**
  36368. * Gets the cached effect (ie. the latest rendered one)
  36369. * @returns the cached effect
  36370. */
  36371. getCachedEffect(): Nullable<Effect>;
  36372. /**
  36373. * Gets the cached visibility state (ie. the latest rendered one)
  36374. * @returns the cached visibility state
  36375. */
  36376. getCachedVisibility(): Nullable<number>;
  36377. /**
  36378. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36379. * @param material defines the current material
  36380. * @param effect defines the current effect
  36381. * @param visibility defines the current visibility state
  36382. * @returns true if one parameter is not cached
  36383. */
  36384. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36385. /**
  36386. * Gets the engine associated with the scene
  36387. * @returns an Engine
  36388. */
  36389. getEngine(): Engine;
  36390. /**
  36391. * Gets the total number of vertices rendered per frame
  36392. * @returns the total number of vertices rendered per frame
  36393. */
  36394. getTotalVertices(): number;
  36395. /**
  36396. * Gets the performance counter for total vertices
  36397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36398. */
  36399. get totalVerticesPerfCounter(): PerfCounter;
  36400. /**
  36401. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36402. * @returns the total number of active indices rendered per frame
  36403. */
  36404. getActiveIndices(): number;
  36405. /**
  36406. * Gets the performance counter for active indices
  36407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36408. */
  36409. get totalActiveIndicesPerfCounter(): PerfCounter;
  36410. /**
  36411. * Gets the total number of active particles rendered per frame
  36412. * @returns the total number of active particles rendered per frame
  36413. */
  36414. getActiveParticles(): number;
  36415. /**
  36416. * Gets the performance counter for active particles
  36417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36418. */
  36419. get activeParticlesPerfCounter(): PerfCounter;
  36420. /**
  36421. * Gets the total number of active bones rendered per frame
  36422. * @returns the total number of active bones rendered per frame
  36423. */
  36424. getActiveBones(): number;
  36425. /**
  36426. * Gets the performance counter for active bones
  36427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36428. */
  36429. get activeBonesPerfCounter(): PerfCounter;
  36430. /**
  36431. * Gets the array of active meshes
  36432. * @returns an array of AbstractMesh
  36433. */
  36434. getActiveMeshes(): SmartArray<AbstractMesh>;
  36435. /**
  36436. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36437. * @returns a number
  36438. */
  36439. getAnimationRatio(): number;
  36440. /**
  36441. * Gets an unique Id for the current render phase
  36442. * @returns a number
  36443. */
  36444. getRenderId(): number;
  36445. /**
  36446. * Gets an unique Id for the current frame
  36447. * @returns a number
  36448. */
  36449. getFrameId(): number;
  36450. /** Call this function if you want to manually increment the render Id*/
  36451. incrementRenderId(): void;
  36452. private _createUbo;
  36453. /**
  36454. * Use this method to simulate a pointer move on a mesh
  36455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36458. * @returns the current scene
  36459. */
  36460. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36461. /**
  36462. * Use this method to simulate a pointer down on a mesh
  36463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36466. * @returns the current scene
  36467. */
  36468. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36469. /**
  36470. * Use this method to simulate a pointer up on a mesh
  36471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36474. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36475. * @returns the current scene
  36476. */
  36477. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36478. /**
  36479. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36480. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36481. * @returns true if the pointer was captured
  36482. */
  36483. isPointerCaptured(pointerId?: number): boolean;
  36484. /**
  36485. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36486. * @param attachUp defines if you want to attach events to pointerup
  36487. * @param attachDown defines if you want to attach events to pointerdown
  36488. * @param attachMove defines if you want to attach events to pointermove
  36489. */
  36490. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36491. /** Detaches all event handlers*/
  36492. detachControl(): void;
  36493. /**
  36494. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36495. * Delay loaded resources are not taking in account
  36496. * @return true if all required resources are ready
  36497. */
  36498. isReady(): boolean;
  36499. /** Resets all cached information relative to material (including effect and visibility) */
  36500. resetCachedMaterial(): void;
  36501. /**
  36502. * Registers a function to be called before every frame render
  36503. * @param func defines the function to register
  36504. */
  36505. registerBeforeRender(func: () => void): void;
  36506. /**
  36507. * Unregisters a function called before every frame render
  36508. * @param func defines the function to unregister
  36509. */
  36510. unregisterBeforeRender(func: () => void): void;
  36511. /**
  36512. * Registers a function to be called after every frame render
  36513. * @param func defines the function to register
  36514. */
  36515. registerAfterRender(func: () => void): void;
  36516. /**
  36517. * Unregisters a function called after every frame render
  36518. * @param func defines the function to unregister
  36519. */
  36520. unregisterAfterRender(func: () => void): void;
  36521. private _executeOnceBeforeRender;
  36522. /**
  36523. * The provided function will run before render once and will be disposed afterwards.
  36524. * A timeout delay can be provided so that the function will be executed in N ms.
  36525. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36526. * @param func The function to be executed.
  36527. * @param timeout optional delay in ms
  36528. */
  36529. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36530. /** @hidden */
  36531. _addPendingData(data: any): void;
  36532. /** @hidden */
  36533. _removePendingData(data: any): void;
  36534. /**
  36535. * Returns the number of items waiting to be loaded
  36536. * @returns the number of items waiting to be loaded
  36537. */
  36538. getWaitingItemsCount(): number;
  36539. /**
  36540. * Returns a boolean indicating if the scene is still loading data
  36541. */
  36542. get isLoading(): boolean;
  36543. /**
  36544. * Registers a function to be executed when the scene is ready
  36545. * @param {Function} func - the function to be executed
  36546. */
  36547. executeWhenReady(func: () => void): void;
  36548. /**
  36549. * Returns a promise that resolves when the scene is ready
  36550. * @returns A promise that resolves when the scene is ready
  36551. */
  36552. whenReadyAsync(): Promise<void>;
  36553. /** @hidden */
  36554. _checkIsReady(): void;
  36555. /**
  36556. * Gets all animatable attached to the scene
  36557. */
  36558. get animatables(): Animatable[];
  36559. /**
  36560. * Resets the last animation time frame.
  36561. * Useful to override when animations start running when loading a scene for the first time.
  36562. */
  36563. resetLastAnimationTimeFrame(): void;
  36564. /**
  36565. * Gets the current view matrix
  36566. * @returns a Matrix
  36567. */
  36568. getViewMatrix(): Matrix;
  36569. /**
  36570. * Gets the current projection matrix
  36571. * @returns a Matrix
  36572. */
  36573. getProjectionMatrix(): Matrix;
  36574. /**
  36575. * Gets the current transform matrix
  36576. * @returns a Matrix made of View * Projection
  36577. */
  36578. getTransformMatrix(): Matrix;
  36579. /**
  36580. * Sets the current transform matrix
  36581. * @param viewL defines the View matrix to use
  36582. * @param projectionL defines the Projection matrix to use
  36583. * @param viewR defines the right View matrix to use (if provided)
  36584. * @param projectionR defines the right Projection matrix to use (if provided)
  36585. */
  36586. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36587. /**
  36588. * Gets the uniform buffer used to store scene data
  36589. * @returns a UniformBuffer
  36590. */
  36591. getSceneUniformBuffer(): UniformBuffer;
  36592. /**
  36593. * Gets an unique (relatively to the current scene) Id
  36594. * @returns an unique number for the scene
  36595. */
  36596. getUniqueId(): number;
  36597. /**
  36598. * Add a mesh to the list of scene's meshes
  36599. * @param newMesh defines the mesh to add
  36600. * @param recursive if all child meshes should also be added to the scene
  36601. */
  36602. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36603. /**
  36604. * Remove a mesh for the list of scene's meshes
  36605. * @param toRemove defines the mesh to remove
  36606. * @param recursive if all child meshes should also be removed from the scene
  36607. * @returns the index where the mesh was in the mesh list
  36608. */
  36609. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36610. /**
  36611. * Add a transform node to the list of scene's transform nodes
  36612. * @param newTransformNode defines the transform node to add
  36613. */
  36614. addTransformNode(newTransformNode: TransformNode): void;
  36615. /**
  36616. * Remove a transform node for the list of scene's transform nodes
  36617. * @param toRemove defines the transform node to remove
  36618. * @returns the index where the transform node was in the transform node list
  36619. */
  36620. removeTransformNode(toRemove: TransformNode): number;
  36621. /**
  36622. * Remove a skeleton for the list of scene's skeletons
  36623. * @param toRemove defines the skeleton to remove
  36624. * @returns the index where the skeleton was in the skeleton list
  36625. */
  36626. removeSkeleton(toRemove: Skeleton): number;
  36627. /**
  36628. * Remove a morph target for the list of scene's morph targets
  36629. * @param toRemove defines the morph target to remove
  36630. * @returns the index where the morph target was in the morph target list
  36631. */
  36632. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36633. /**
  36634. * Remove a light for the list of scene's lights
  36635. * @param toRemove defines the light to remove
  36636. * @returns the index where the light was in the light list
  36637. */
  36638. removeLight(toRemove: Light): number;
  36639. /**
  36640. * Remove a camera for the list of scene's cameras
  36641. * @param toRemove defines the camera to remove
  36642. * @returns the index where the camera was in the camera list
  36643. */
  36644. removeCamera(toRemove: Camera): number;
  36645. /**
  36646. * Remove a particle system for the list of scene's particle systems
  36647. * @param toRemove defines the particle system to remove
  36648. * @returns the index where the particle system was in the particle system list
  36649. */
  36650. removeParticleSystem(toRemove: IParticleSystem): number;
  36651. /**
  36652. * Remove a animation for the list of scene's animations
  36653. * @param toRemove defines the animation to remove
  36654. * @returns the index where the animation was in the animation list
  36655. */
  36656. removeAnimation(toRemove: Animation): number;
  36657. /**
  36658. * Will stop the animation of the given target
  36659. * @param target - the target
  36660. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36661. * @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)
  36662. */
  36663. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36664. /**
  36665. * Removes the given animation group from this scene.
  36666. * @param toRemove The animation group to remove
  36667. * @returns The index of the removed animation group
  36668. */
  36669. removeAnimationGroup(toRemove: AnimationGroup): number;
  36670. /**
  36671. * Removes the given multi-material from this scene.
  36672. * @param toRemove The multi-material to remove
  36673. * @returns The index of the removed multi-material
  36674. */
  36675. removeMultiMaterial(toRemove: MultiMaterial): number;
  36676. /**
  36677. * Removes the given material from this scene.
  36678. * @param toRemove The material to remove
  36679. * @returns The index of the removed material
  36680. */
  36681. removeMaterial(toRemove: Material): number;
  36682. /**
  36683. * Removes the given action manager from this scene.
  36684. * @param toRemove The action manager to remove
  36685. * @returns The index of the removed action manager
  36686. */
  36687. removeActionManager(toRemove: AbstractActionManager): number;
  36688. /**
  36689. * Removes the given texture from this scene.
  36690. * @param toRemove The texture to remove
  36691. * @returns The index of the removed texture
  36692. */
  36693. removeTexture(toRemove: BaseTexture): number;
  36694. /**
  36695. * Adds the given light to this scene
  36696. * @param newLight The light to add
  36697. */
  36698. addLight(newLight: Light): void;
  36699. /**
  36700. * Sorts the list list based on light priorities
  36701. */
  36702. sortLightsByPriority(): void;
  36703. /**
  36704. * Adds the given camera to this scene
  36705. * @param newCamera The camera to add
  36706. */
  36707. addCamera(newCamera: Camera): void;
  36708. /**
  36709. * Adds the given skeleton to this scene
  36710. * @param newSkeleton The skeleton to add
  36711. */
  36712. addSkeleton(newSkeleton: Skeleton): void;
  36713. /**
  36714. * Adds the given particle system to this scene
  36715. * @param newParticleSystem The particle system to add
  36716. */
  36717. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36718. /**
  36719. * Adds the given animation to this scene
  36720. * @param newAnimation The animation to add
  36721. */
  36722. addAnimation(newAnimation: Animation): void;
  36723. /**
  36724. * Adds the given animation group to this scene.
  36725. * @param newAnimationGroup The animation group to add
  36726. */
  36727. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36728. /**
  36729. * Adds the given multi-material to this scene
  36730. * @param newMultiMaterial The multi-material to add
  36731. */
  36732. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36733. /**
  36734. * Adds the given material to this scene
  36735. * @param newMaterial The material to add
  36736. */
  36737. addMaterial(newMaterial: Material): void;
  36738. /**
  36739. * Adds the given morph target to this scene
  36740. * @param newMorphTargetManager The morph target to add
  36741. */
  36742. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36743. /**
  36744. * Adds the given geometry to this scene
  36745. * @param newGeometry The geometry to add
  36746. */
  36747. addGeometry(newGeometry: Geometry): void;
  36748. /**
  36749. * Adds the given action manager to this scene
  36750. * @param newActionManager The action manager to add
  36751. */
  36752. addActionManager(newActionManager: AbstractActionManager): void;
  36753. /**
  36754. * Adds the given texture to this scene.
  36755. * @param newTexture The texture to add
  36756. */
  36757. addTexture(newTexture: BaseTexture): void;
  36758. /**
  36759. * Switch active camera
  36760. * @param newCamera defines the new active camera
  36761. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36762. */
  36763. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36764. /**
  36765. * sets the active camera of the scene using its ID
  36766. * @param id defines the camera's ID
  36767. * @return the new active camera or null if none found.
  36768. */
  36769. setActiveCameraByID(id: string): Nullable<Camera>;
  36770. /**
  36771. * sets the active camera of the scene using its name
  36772. * @param name defines the camera's name
  36773. * @returns the new active camera or null if none found.
  36774. */
  36775. setActiveCameraByName(name: string): Nullable<Camera>;
  36776. /**
  36777. * get an animation group using its name
  36778. * @param name defines the material's name
  36779. * @return the animation group or null if none found.
  36780. */
  36781. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36782. /**
  36783. * Get a material using its unique id
  36784. * @param uniqueId defines the material's unique id
  36785. * @return the material or null if none found.
  36786. */
  36787. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36788. /**
  36789. * get a material using its id
  36790. * @param id defines the material's ID
  36791. * @return the material or null if none found.
  36792. */
  36793. getMaterialByID(id: string): Nullable<Material>;
  36794. /**
  36795. * Gets a the last added material using a given id
  36796. * @param id defines the material's ID
  36797. * @return the last material with the given id or null if none found.
  36798. */
  36799. getLastMaterialByID(id: string): Nullable<Material>;
  36800. /**
  36801. * Gets a material using its name
  36802. * @param name defines the material's name
  36803. * @return the material or null if none found.
  36804. */
  36805. getMaterialByName(name: string): Nullable<Material>;
  36806. /**
  36807. * Get a texture using its unique id
  36808. * @param uniqueId defines the texture's unique id
  36809. * @return the texture or null if none found.
  36810. */
  36811. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36812. /**
  36813. * Gets a camera using its id
  36814. * @param id defines the id to look for
  36815. * @returns the camera or null if not found
  36816. */
  36817. getCameraByID(id: string): Nullable<Camera>;
  36818. /**
  36819. * Gets a camera using its unique id
  36820. * @param uniqueId defines the unique id to look for
  36821. * @returns the camera or null if not found
  36822. */
  36823. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36824. /**
  36825. * Gets a camera using its name
  36826. * @param name defines the camera's name
  36827. * @return the camera or null if none found.
  36828. */
  36829. getCameraByName(name: string): Nullable<Camera>;
  36830. /**
  36831. * Gets a bone using its id
  36832. * @param id defines the bone's id
  36833. * @return the bone or null if not found
  36834. */
  36835. getBoneByID(id: string): Nullable<Bone>;
  36836. /**
  36837. * Gets a bone using its id
  36838. * @param name defines the bone's name
  36839. * @return the bone or null if not found
  36840. */
  36841. getBoneByName(name: string): Nullable<Bone>;
  36842. /**
  36843. * Gets a light node using its name
  36844. * @param name defines the the light's name
  36845. * @return the light or null if none found.
  36846. */
  36847. getLightByName(name: string): Nullable<Light>;
  36848. /**
  36849. * Gets a light node using its id
  36850. * @param id defines the light's id
  36851. * @return the light or null if none found.
  36852. */
  36853. getLightByID(id: string): Nullable<Light>;
  36854. /**
  36855. * Gets a light node using its scene-generated unique ID
  36856. * @param uniqueId defines the light's unique id
  36857. * @return the light or null if none found.
  36858. */
  36859. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36860. /**
  36861. * Gets a particle system by id
  36862. * @param id defines the particle system id
  36863. * @return the corresponding system or null if none found
  36864. */
  36865. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36866. /**
  36867. * Gets a geometry using its ID
  36868. * @param id defines the geometry's id
  36869. * @return the geometry or null if none found.
  36870. */
  36871. getGeometryByID(id: string): Nullable<Geometry>;
  36872. private _getGeometryByUniqueID;
  36873. /**
  36874. * Add a new geometry to this scene
  36875. * @param geometry defines the geometry to be added to the scene.
  36876. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36877. * @return a boolean defining if the geometry was added or not
  36878. */
  36879. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36880. /**
  36881. * Removes an existing geometry
  36882. * @param geometry defines the geometry to be removed from the scene
  36883. * @return a boolean defining if the geometry was removed or not
  36884. */
  36885. removeGeometry(geometry: Geometry): boolean;
  36886. /**
  36887. * Gets the list of geometries attached to the scene
  36888. * @returns an array of Geometry
  36889. */
  36890. getGeometries(): Geometry[];
  36891. /**
  36892. * Gets the first added mesh found of a given ID
  36893. * @param id defines the id to search for
  36894. * @return the mesh found or null if not found at all
  36895. */
  36896. getMeshByID(id: string): Nullable<AbstractMesh>;
  36897. /**
  36898. * Gets a list of meshes using their id
  36899. * @param id defines the id to search for
  36900. * @returns a list of meshes
  36901. */
  36902. getMeshesByID(id: string): Array<AbstractMesh>;
  36903. /**
  36904. * Gets the first added transform node found of a given ID
  36905. * @param id defines the id to search for
  36906. * @return the found transform node or null if not found at all.
  36907. */
  36908. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36909. /**
  36910. * Gets a transform node with its auto-generated unique id
  36911. * @param uniqueId efines the unique id to search for
  36912. * @return the found transform node or null if not found at all.
  36913. */
  36914. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36915. /**
  36916. * Gets a list of transform nodes using their id
  36917. * @param id defines the id to search for
  36918. * @returns a list of transform nodes
  36919. */
  36920. getTransformNodesByID(id: string): Array<TransformNode>;
  36921. /**
  36922. * Gets a mesh with its auto-generated unique id
  36923. * @param uniqueId defines the unique id to search for
  36924. * @return the found mesh or null if not found at all.
  36925. */
  36926. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36927. /**
  36928. * Gets a the last added mesh using a given id
  36929. * @param id defines the id to search for
  36930. * @return the found mesh or null if not found at all.
  36931. */
  36932. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36933. /**
  36934. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36935. * @param id defines the id to search for
  36936. * @return the found node or null if not found at all
  36937. */
  36938. getLastEntryByID(id: string): Nullable<Node>;
  36939. /**
  36940. * Gets a node (Mesh, Camera, Light) using a given id
  36941. * @param id defines the id to search for
  36942. * @return the found node or null if not found at all
  36943. */
  36944. getNodeByID(id: string): Nullable<Node>;
  36945. /**
  36946. * Gets a node (Mesh, Camera, Light) using a given name
  36947. * @param name defines the name to search for
  36948. * @return the found node or null if not found at all.
  36949. */
  36950. getNodeByName(name: string): Nullable<Node>;
  36951. /**
  36952. * Gets a mesh using a given name
  36953. * @param name defines the name to search for
  36954. * @return the found mesh or null if not found at all.
  36955. */
  36956. getMeshByName(name: string): Nullable<AbstractMesh>;
  36957. /**
  36958. * Gets a transform node using a given name
  36959. * @param name defines the name to search for
  36960. * @return the found transform node or null if not found at all.
  36961. */
  36962. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36963. /**
  36964. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36965. * @param id defines the id to search for
  36966. * @return the found skeleton or null if not found at all.
  36967. */
  36968. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36969. /**
  36970. * Gets a skeleton using a given auto generated unique id
  36971. * @param uniqueId defines the unique id to search for
  36972. * @return the found skeleton or null if not found at all.
  36973. */
  36974. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36975. /**
  36976. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36977. * @param id defines the id to search for
  36978. * @return the found skeleton or null if not found at all.
  36979. */
  36980. getSkeletonById(id: string): Nullable<Skeleton>;
  36981. /**
  36982. * Gets a skeleton using a given name
  36983. * @param name defines the name to search for
  36984. * @return the found skeleton or null if not found at all.
  36985. */
  36986. getSkeletonByName(name: string): Nullable<Skeleton>;
  36987. /**
  36988. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36989. * @param id defines the id to search for
  36990. * @return the found morph target manager or null if not found at all.
  36991. */
  36992. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36993. /**
  36994. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36995. * @param id defines the id to search for
  36996. * @return the found morph target or null if not found at all.
  36997. */
  36998. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36999. /**
  37000. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37001. * @param name defines the name to search for
  37002. * @return the found morph target or null if not found at all.
  37003. */
  37004. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37005. /**
  37006. * Gets a boolean indicating if the given mesh is active
  37007. * @param mesh defines the mesh to look for
  37008. * @returns true if the mesh is in the active list
  37009. */
  37010. isActiveMesh(mesh: AbstractMesh): boolean;
  37011. /**
  37012. * Return a unique id as a string which can serve as an identifier for the scene
  37013. */
  37014. get uid(): string;
  37015. /**
  37016. * Add an externaly attached data from its key.
  37017. * This method call will fail and return false, if such key already exists.
  37018. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37019. * @param key the unique key that identifies the data
  37020. * @param data the data object to associate to the key for this Engine instance
  37021. * @return true if no such key were already present and the data was added successfully, false otherwise
  37022. */
  37023. addExternalData<T>(key: string, data: T): boolean;
  37024. /**
  37025. * Get an externaly attached data from its key
  37026. * @param key the unique key that identifies the data
  37027. * @return the associated data, if present (can be null), or undefined if not present
  37028. */
  37029. getExternalData<T>(key: string): Nullable<T>;
  37030. /**
  37031. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37032. * @param key the unique key that identifies the data
  37033. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37034. * @return the associated data, can be null if the factory returned null.
  37035. */
  37036. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37037. /**
  37038. * Remove an externaly attached data from the Engine instance
  37039. * @param key the unique key that identifies the data
  37040. * @return true if the data was successfully removed, false if it doesn't exist
  37041. */
  37042. removeExternalData(key: string): boolean;
  37043. private _evaluateSubMesh;
  37044. /**
  37045. * Clear the processed materials smart array preventing retention point in material dispose.
  37046. */
  37047. freeProcessedMaterials(): void;
  37048. private _preventFreeActiveMeshesAndRenderingGroups;
  37049. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37050. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37051. * when disposing several meshes in a row or a hierarchy of meshes.
  37052. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37053. */
  37054. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37055. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37056. /**
  37057. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37058. */
  37059. freeActiveMeshes(): void;
  37060. /**
  37061. * Clear the info related to rendering groups preventing retention points during dispose.
  37062. */
  37063. freeRenderingGroups(): void;
  37064. /** @hidden */
  37065. _isInIntermediateRendering(): boolean;
  37066. /**
  37067. * Lambda returning the list of potentially active meshes.
  37068. */
  37069. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37070. /**
  37071. * Lambda returning the list of potentially active sub meshes.
  37072. */
  37073. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37074. /**
  37075. * Lambda returning the list of potentially intersecting sub meshes.
  37076. */
  37077. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37078. /**
  37079. * Lambda returning the list of potentially colliding sub meshes.
  37080. */
  37081. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37082. private _activeMeshesFrozen;
  37083. private _skipEvaluateActiveMeshesCompletely;
  37084. /**
  37085. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37086. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37087. * @returns the current scene
  37088. */
  37089. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37090. /**
  37091. * Use this function to restart evaluating active meshes on every frame
  37092. * @returns the current scene
  37093. */
  37094. unfreezeActiveMeshes(): Scene;
  37095. private _evaluateActiveMeshes;
  37096. private _activeMesh;
  37097. /**
  37098. * Update the transform matrix to update from the current active camera
  37099. * @param force defines a boolean used to force the update even if cache is up to date
  37100. */
  37101. updateTransformMatrix(force?: boolean): void;
  37102. private _bindFrameBuffer;
  37103. /** @hidden */
  37104. _allowPostProcessClearColor: boolean;
  37105. /** @hidden */
  37106. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37107. private _processSubCameras;
  37108. private _checkIntersections;
  37109. /** @hidden */
  37110. _advancePhysicsEngineStep(step: number): void;
  37111. /**
  37112. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37113. */
  37114. getDeterministicFrameTime: () => number;
  37115. /** @hidden */
  37116. _animate(): void;
  37117. /** Execute all animations (for a frame) */
  37118. animate(): void;
  37119. /**
  37120. * Render the scene
  37121. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37122. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37123. */
  37124. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37125. /**
  37126. * Freeze all materials
  37127. * A frozen material will not be updatable but should be faster to render
  37128. */
  37129. freezeMaterials(): void;
  37130. /**
  37131. * Unfreeze all materials
  37132. * A frozen material will not be updatable but should be faster to render
  37133. */
  37134. unfreezeMaterials(): void;
  37135. /**
  37136. * Releases all held ressources
  37137. */
  37138. dispose(): void;
  37139. /**
  37140. * Gets if the scene is already disposed
  37141. */
  37142. get isDisposed(): boolean;
  37143. /**
  37144. * Call this function to reduce memory footprint of the scene.
  37145. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37146. */
  37147. clearCachedVertexData(): void;
  37148. /**
  37149. * This function will remove the local cached buffer data from texture.
  37150. * It will save memory but will prevent the texture from being rebuilt
  37151. */
  37152. cleanCachedTextureBuffer(): void;
  37153. /**
  37154. * Get the world extend vectors with an optional filter
  37155. *
  37156. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37157. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37158. */
  37159. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37160. min: Vector3;
  37161. max: Vector3;
  37162. };
  37163. /**
  37164. * Creates a ray that can be used to pick in the scene
  37165. * @param x defines the x coordinate of the origin (on-screen)
  37166. * @param y defines the y coordinate of the origin (on-screen)
  37167. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37168. * @param camera defines the camera to use for the picking
  37169. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37170. * @returns a Ray
  37171. */
  37172. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37173. /**
  37174. * Creates a ray that can be used to pick in the scene
  37175. * @param x defines the x coordinate of the origin (on-screen)
  37176. * @param y defines the y coordinate of the origin (on-screen)
  37177. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37178. * @param result defines the ray where to store the picking ray
  37179. * @param camera defines the camera to use for the picking
  37180. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37181. * @returns the current scene
  37182. */
  37183. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37184. /**
  37185. * Creates a ray that can be used to pick in the scene
  37186. * @param x defines the x coordinate of the origin (on-screen)
  37187. * @param y defines the y coordinate of the origin (on-screen)
  37188. * @param camera defines the camera to use for the picking
  37189. * @returns a Ray
  37190. */
  37191. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37192. /**
  37193. * Creates a ray that can be used to pick in the scene
  37194. * @param x defines the x coordinate of the origin (on-screen)
  37195. * @param y defines the y coordinate of the origin (on-screen)
  37196. * @param result defines the ray where to store the picking ray
  37197. * @param camera defines the camera to use for the picking
  37198. * @returns the current scene
  37199. */
  37200. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37201. /** Launch a ray to try to pick a mesh in the scene
  37202. * @param x position on screen
  37203. * @param y position on screen
  37204. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37205. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37206. * @param 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 a PickingInfo
  37209. */
  37210. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37211. /** Use the given ray to pick a mesh in the scene
  37212. * @param ray The ray to use to pick meshes
  37213. * @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
  37214. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37216. * @returns a PickingInfo
  37217. */
  37218. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37219. /**
  37220. * Launch a ray to try to pick a mesh in the scene
  37221. * @param x X position on screen
  37222. * @param y Y position on screen
  37223. * @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
  37224. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37226. * @returns an array of PickingInfo
  37227. */
  37228. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37229. /**
  37230. * Launch a ray to try to pick a mesh in the scene
  37231. * @param ray Ray to use
  37232. * @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
  37233. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37234. * @returns an array of PickingInfo
  37235. */
  37236. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37237. /**
  37238. * Force the value of meshUnderPointer
  37239. * @param mesh defines the mesh to use
  37240. */
  37241. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37242. /**
  37243. * Gets the mesh under the pointer
  37244. * @returns a Mesh or null if no mesh is under the pointer
  37245. */
  37246. getPointerOverMesh(): Nullable<AbstractMesh>;
  37247. /** @hidden */
  37248. _rebuildGeometries(): void;
  37249. /** @hidden */
  37250. _rebuildTextures(): void;
  37251. private _getByTags;
  37252. /**
  37253. * Get a list of meshes by tags
  37254. * @param tagsQuery defines the tags query to use
  37255. * @param forEach defines a predicate used to filter results
  37256. * @returns an array of Mesh
  37257. */
  37258. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37259. /**
  37260. * Get a list of cameras by tags
  37261. * @param tagsQuery defines the tags query to use
  37262. * @param forEach defines a predicate used to filter results
  37263. * @returns an array of Camera
  37264. */
  37265. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37266. /**
  37267. * Get a list of lights by tags
  37268. * @param tagsQuery defines the tags query to use
  37269. * @param forEach defines a predicate used to filter results
  37270. * @returns an array of Light
  37271. */
  37272. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37273. /**
  37274. * Get a list of materials by tags
  37275. * @param tagsQuery defines the tags query to use
  37276. * @param forEach defines a predicate used to filter results
  37277. * @returns an array of Material
  37278. */
  37279. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37280. /**
  37281. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37282. * This allowed control for front to back rendering or reversly depending of the special needs.
  37283. *
  37284. * @param renderingGroupId The rendering group id corresponding to its index
  37285. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37286. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37287. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37288. */
  37289. 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;
  37290. /**
  37291. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37292. *
  37293. * @param renderingGroupId The rendering group id corresponding to its index
  37294. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37295. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37296. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37297. */
  37298. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37299. /**
  37300. * Gets the current auto clear configuration for one rendering group of the rendering
  37301. * manager.
  37302. * @param index the rendering group index to get the information for
  37303. * @returns The auto clear setup for the requested rendering group
  37304. */
  37305. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37306. private _blockMaterialDirtyMechanism;
  37307. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37308. get blockMaterialDirtyMechanism(): boolean;
  37309. set blockMaterialDirtyMechanism(value: boolean);
  37310. /**
  37311. * Will flag all materials as dirty to trigger new shader compilation
  37312. * @param flag defines the flag used to specify which material part must be marked as dirty
  37313. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37314. */
  37315. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37316. /** @hidden */
  37317. _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;
  37318. /** @hidden */
  37319. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37320. /** @hidden */
  37321. _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;
  37322. /** @hidden */
  37323. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37324. /** @hidden */
  37325. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37326. /** @hidden */
  37327. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37328. }
  37329. }
  37330. declare module BABYLON {
  37331. /**
  37332. * Set of assets to keep when moving a scene into an asset container.
  37333. */
  37334. export class KeepAssets extends AbstractScene {
  37335. }
  37336. /**
  37337. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37338. */
  37339. export class InstantiatedEntries {
  37340. /**
  37341. * List of new root nodes (eg. nodes with no parent)
  37342. */
  37343. rootNodes: TransformNode[];
  37344. /**
  37345. * List of new skeletons
  37346. */
  37347. skeletons: Skeleton[];
  37348. /**
  37349. * List of new animation groups
  37350. */
  37351. animationGroups: AnimationGroup[];
  37352. }
  37353. /**
  37354. * Container with a set of assets that can be added or removed from a scene.
  37355. */
  37356. export class AssetContainer extends AbstractScene {
  37357. private _wasAddedToScene;
  37358. /**
  37359. * The scene the AssetContainer belongs to.
  37360. */
  37361. scene: Scene;
  37362. /**
  37363. * Instantiates an AssetContainer.
  37364. * @param scene The scene the AssetContainer belongs to.
  37365. */
  37366. constructor(scene: Scene);
  37367. /**
  37368. * Instantiate or clone all meshes and add the new ones to the scene.
  37369. * Skeletons and animation groups will all be cloned
  37370. * @param nameFunction defines an optional function used to get new names for clones
  37371. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37372. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37373. */
  37374. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37375. /**
  37376. * Adds all the assets from the container to the scene.
  37377. */
  37378. addAllToScene(): void;
  37379. /**
  37380. * Removes all the assets in the container from the scene
  37381. */
  37382. removeAllFromScene(): void;
  37383. /**
  37384. * Disposes all the assets in the container
  37385. */
  37386. dispose(): void;
  37387. private _moveAssets;
  37388. /**
  37389. * Removes all the assets contained in the scene and adds them to the container.
  37390. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37391. */
  37392. moveAllFromScene(keepAssets?: KeepAssets): void;
  37393. /**
  37394. * 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.
  37395. * @returns the root mesh
  37396. */
  37397. createRootMesh(): Mesh;
  37398. /**
  37399. * Merge animations from this asset container into a scene
  37400. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37401. * @param animatables set of animatables to retarget to a node from the scene
  37402. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37403. */
  37404. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37405. }
  37406. }
  37407. declare module BABYLON {
  37408. /**
  37409. * Defines how the parser contract is defined.
  37410. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37411. */
  37412. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37413. /**
  37414. * Defines how the individual parser contract is defined.
  37415. * These parser can parse an individual asset
  37416. */
  37417. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37418. /**
  37419. * Base class of the scene acting as a container for the different elements composing a scene.
  37420. * This class is dynamically extended by the different components of the scene increasing
  37421. * flexibility and reducing coupling
  37422. */
  37423. export abstract class AbstractScene {
  37424. /**
  37425. * Stores the list of available parsers in the application.
  37426. */
  37427. private static _BabylonFileParsers;
  37428. /**
  37429. * Stores the list of available individual parsers in the application.
  37430. */
  37431. private static _IndividualBabylonFileParsers;
  37432. /**
  37433. * Adds a parser in the list of available ones
  37434. * @param name Defines the name of the parser
  37435. * @param parser Defines the parser to add
  37436. */
  37437. static AddParser(name: string, parser: BabylonFileParser): void;
  37438. /**
  37439. * Gets a general parser from the list of avaialble ones
  37440. * @param name Defines the name of the parser
  37441. * @returns the requested parser or null
  37442. */
  37443. static GetParser(name: string): Nullable<BabylonFileParser>;
  37444. /**
  37445. * Adds n individual parser in the list of available ones
  37446. * @param name Defines the name of the parser
  37447. * @param parser Defines the parser to add
  37448. */
  37449. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37450. /**
  37451. * Gets an individual parser from the list of avaialble ones
  37452. * @param name Defines the name of the parser
  37453. * @returns the requested parser or null
  37454. */
  37455. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37456. /**
  37457. * Parser json data and populate both a scene and its associated container object
  37458. * @param jsonData Defines the data to parse
  37459. * @param scene Defines the scene to parse the data for
  37460. * @param container Defines the container attached to the parsing sequence
  37461. * @param rootUrl Defines the root url of the data
  37462. */
  37463. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37464. /**
  37465. * Gets the list of root nodes (ie. nodes with no parent)
  37466. */
  37467. rootNodes: Node[];
  37468. /** All of the cameras added to this scene
  37469. * @see http://doc.babylonjs.com/babylon101/cameras
  37470. */
  37471. cameras: Camera[];
  37472. /**
  37473. * All of the lights added to this scene
  37474. * @see http://doc.babylonjs.com/babylon101/lights
  37475. */
  37476. lights: Light[];
  37477. /**
  37478. * All of the (abstract) meshes added to this scene
  37479. */
  37480. meshes: AbstractMesh[];
  37481. /**
  37482. * The list of skeletons added to the scene
  37483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37484. */
  37485. skeletons: Skeleton[];
  37486. /**
  37487. * All of the particle systems added to this scene
  37488. * @see http://doc.babylonjs.com/babylon101/particles
  37489. */
  37490. particleSystems: IParticleSystem[];
  37491. /**
  37492. * Gets a list of Animations associated with the scene
  37493. */
  37494. animations: Animation[];
  37495. /**
  37496. * All of the animation groups added to this scene
  37497. * @see http://doc.babylonjs.com/how_to/group
  37498. */
  37499. animationGroups: AnimationGroup[];
  37500. /**
  37501. * All of the multi-materials added to this scene
  37502. * @see http://doc.babylonjs.com/how_to/multi_materials
  37503. */
  37504. multiMaterials: MultiMaterial[];
  37505. /**
  37506. * All of the materials added to this scene
  37507. * In the context of a Scene, it is not supposed to be modified manually.
  37508. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37509. * Note also that the order of the Material within the array is not significant and might change.
  37510. * @see http://doc.babylonjs.com/babylon101/materials
  37511. */
  37512. materials: Material[];
  37513. /**
  37514. * The list of morph target managers added to the scene
  37515. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37516. */
  37517. morphTargetManagers: MorphTargetManager[];
  37518. /**
  37519. * The list of geometries used in the scene.
  37520. */
  37521. geometries: Geometry[];
  37522. /**
  37523. * All of the tranform nodes added to this scene
  37524. * In the context of a Scene, it is not supposed to be modified manually.
  37525. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37526. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37527. * @see http://doc.babylonjs.com/how_to/transformnode
  37528. */
  37529. transformNodes: TransformNode[];
  37530. /**
  37531. * ActionManagers available on the scene.
  37532. */
  37533. actionManagers: AbstractActionManager[];
  37534. /**
  37535. * Textures to keep.
  37536. */
  37537. textures: BaseTexture[];
  37538. /**
  37539. * Environment texture for the scene
  37540. */
  37541. environmentTexture: Nullable<BaseTexture>;
  37542. /**
  37543. * @returns all meshes, lights, cameras, transformNodes and bones
  37544. */
  37545. getNodes(): Array<Node>;
  37546. }
  37547. }
  37548. declare module BABYLON {
  37549. /**
  37550. * Interface used to define options for Sound class
  37551. */
  37552. export interface ISoundOptions {
  37553. /**
  37554. * Does the sound autoplay once loaded.
  37555. */
  37556. autoplay?: boolean;
  37557. /**
  37558. * Does the sound loop after it finishes playing once.
  37559. */
  37560. loop?: boolean;
  37561. /**
  37562. * Sound's volume
  37563. */
  37564. volume?: number;
  37565. /**
  37566. * Is it a spatial sound?
  37567. */
  37568. spatialSound?: boolean;
  37569. /**
  37570. * Maximum distance to hear that sound
  37571. */
  37572. maxDistance?: number;
  37573. /**
  37574. * Uses user defined attenuation function
  37575. */
  37576. useCustomAttenuation?: boolean;
  37577. /**
  37578. * Define the roll off factor of spatial sounds.
  37579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37580. */
  37581. rolloffFactor?: number;
  37582. /**
  37583. * Define the reference distance the sound should be heard perfectly.
  37584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37585. */
  37586. refDistance?: number;
  37587. /**
  37588. * Define the distance attenuation model the sound will follow.
  37589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37590. */
  37591. distanceModel?: string;
  37592. /**
  37593. * Defines the playback speed (1 by default)
  37594. */
  37595. playbackRate?: number;
  37596. /**
  37597. * Defines if the sound is from a streaming source
  37598. */
  37599. streaming?: boolean;
  37600. /**
  37601. * Defines an optional length (in seconds) inside the sound file
  37602. */
  37603. length?: number;
  37604. /**
  37605. * Defines an optional offset (in seconds) inside the sound file
  37606. */
  37607. offset?: number;
  37608. /**
  37609. * If true, URLs will not be required to state the audio file codec to use.
  37610. */
  37611. skipCodecCheck?: boolean;
  37612. }
  37613. /**
  37614. * Defines a sound that can be played in the application.
  37615. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37617. */
  37618. export class Sound {
  37619. /**
  37620. * The name of the sound in the scene.
  37621. */
  37622. name: string;
  37623. /**
  37624. * Does the sound autoplay once loaded.
  37625. */
  37626. autoplay: boolean;
  37627. /**
  37628. * Does the sound loop after it finishes playing once.
  37629. */
  37630. loop: boolean;
  37631. /**
  37632. * Does the sound use a custom attenuation curve to simulate the falloff
  37633. * happening when the source gets further away from the camera.
  37634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37635. */
  37636. useCustomAttenuation: boolean;
  37637. /**
  37638. * The sound track id this sound belongs to.
  37639. */
  37640. soundTrackId: number;
  37641. /**
  37642. * Is this sound currently played.
  37643. */
  37644. isPlaying: boolean;
  37645. /**
  37646. * Is this sound currently paused.
  37647. */
  37648. isPaused: boolean;
  37649. /**
  37650. * Does this sound enables spatial sound.
  37651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37652. */
  37653. spatialSound: boolean;
  37654. /**
  37655. * Define the reference distance the sound should be heard perfectly.
  37656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37657. */
  37658. refDistance: number;
  37659. /**
  37660. * Define the roll off factor of spatial sounds.
  37661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37662. */
  37663. rolloffFactor: number;
  37664. /**
  37665. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37667. */
  37668. maxDistance: number;
  37669. /**
  37670. * Define the distance attenuation model the sound will follow.
  37671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37672. */
  37673. distanceModel: string;
  37674. /**
  37675. * @hidden
  37676. * Back Compat
  37677. **/
  37678. onended: () => any;
  37679. /**
  37680. * Observable event when the current playing sound finishes.
  37681. */
  37682. onEndedObservable: Observable<Sound>;
  37683. private _panningModel;
  37684. private _playbackRate;
  37685. private _streaming;
  37686. private _startTime;
  37687. private _startOffset;
  37688. private _position;
  37689. /** @hidden */
  37690. _positionInEmitterSpace: boolean;
  37691. private _localDirection;
  37692. private _volume;
  37693. private _isReadyToPlay;
  37694. private _isDirectional;
  37695. private _readyToPlayCallback;
  37696. private _audioBuffer;
  37697. private _soundSource;
  37698. private _streamingSource;
  37699. private _soundPanner;
  37700. private _soundGain;
  37701. private _inputAudioNode;
  37702. private _outputAudioNode;
  37703. private _coneInnerAngle;
  37704. private _coneOuterAngle;
  37705. private _coneOuterGain;
  37706. private _scene;
  37707. private _connectedTransformNode;
  37708. private _customAttenuationFunction;
  37709. private _registerFunc;
  37710. private _isOutputConnected;
  37711. private _htmlAudioElement;
  37712. private _urlType;
  37713. private _length?;
  37714. private _offset?;
  37715. /** @hidden */
  37716. static _SceneComponentInitialization: (scene: Scene) => void;
  37717. /**
  37718. * Create a sound and attach it to a scene
  37719. * @param name Name of your sound
  37720. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37721. * @param scene defines the scene the sound belongs to
  37722. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37723. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37724. */
  37725. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37726. /**
  37727. * Release the sound and its associated resources
  37728. */
  37729. dispose(): void;
  37730. /**
  37731. * Gets if the sounds is ready to be played or not.
  37732. * @returns true if ready, otherwise false
  37733. */
  37734. isReady(): boolean;
  37735. private _soundLoaded;
  37736. /**
  37737. * Sets the data of the sound from an audiobuffer
  37738. * @param audioBuffer The audioBuffer containing the data
  37739. */
  37740. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37741. /**
  37742. * Updates the current sounds options such as maxdistance, loop...
  37743. * @param options A JSON object containing values named as the object properties
  37744. */
  37745. updateOptions(options: ISoundOptions): void;
  37746. private _createSpatialParameters;
  37747. private _updateSpatialParameters;
  37748. /**
  37749. * Switch the panning model to HRTF:
  37750. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37752. */
  37753. switchPanningModelToHRTF(): void;
  37754. /**
  37755. * Switch the panning model to Equal Power:
  37756. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37758. */
  37759. switchPanningModelToEqualPower(): void;
  37760. private _switchPanningModel;
  37761. /**
  37762. * Connect this sound to a sound track audio node like gain...
  37763. * @param soundTrackAudioNode the sound track audio node to connect to
  37764. */
  37765. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37766. /**
  37767. * Transform this sound into a directional source
  37768. * @param coneInnerAngle Size of the inner cone in degree
  37769. * @param coneOuterAngle Size of the outer cone in degree
  37770. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37771. */
  37772. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37773. /**
  37774. * Gets or sets the inner angle for the directional cone.
  37775. */
  37776. get directionalConeInnerAngle(): number;
  37777. /**
  37778. * Gets or sets the inner angle for the directional cone.
  37779. */
  37780. set directionalConeInnerAngle(value: number);
  37781. /**
  37782. * Gets or sets the outer angle for the directional cone.
  37783. */
  37784. get directionalConeOuterAngle(): number;
  37785. /**
  37786. * Gets or sets the outer angle for the directional cone.
  37787. */
  37788. set directionalConeOuterAngle(value: number);
  37789. /**
  37790. * Sets the position of the emitter if spatial sound is enabled
  37791. * @param newPosition Defines the new posisiton
  37792. */
  37793. setPosition(newPosition: Vector3): void;
  37794. /**
  37795. * Sets the local direction of the emitter if spatial sound is enabled
  37796. * @param newLocalDirection Defines the new local direction
  37797. */
  37798. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37799. private _updateDirection;
  37800. /** @hidden */
  37801. updateDistanceFromListener(): void;
  37802. /**
  37803. * Sets a new custom attenuation function for the sound.
  37804. * @param callback Defines the function used for the attenuation
  37805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37806. */
  37807. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37808. /**
  37809. * Play the sound
  37810. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37811. * @param offset (optional) Start the sound at a specific time in seconds
  37812. * @param length (optional) Sound duration (in seconds)
  37813. */
  37814. play(time?: number, offset?: number, length?: number): void;
  37815. private _onended;
  37816. /**
  37817. * Stop the sound
  37818. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37819. */
  37820. stop(time?: number): void;
  37821. /**
  37822. * Put the sound in pause
  37823. */
  37824. pause(): void;
  37825. /**
  37826. * Sets a dedicated volume for this sounds
  37827. * @param newVolume Define the new volume of the sound
  37828. * @param time Define time for gradual change to new volume
  37829. */
  37830. setVolume(newVolume: number, time?: number): void;
  37831. /**
  37832. * Set the sound play back rate
  37833. * @param newPlaybackRate Define the playback rate the sound should be played at
  37834. */
  37835. setPlaybackRate(newPlaybackRate: number): void;
  37836. /**
  37837. * Gets the volume of the sound.
  37838. * @returns the volume of the sound
  37839. */
  37840. getVolume(): number;
  37841. /**
  37842. * Attach the sound to a dedicated mesh
  37843. * @param transformNode The transform node to connect the sound with
  37844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37845. */
  37846. attachToMesh(transformNode: TransformNode): void;
  37847. /**
  37848. * Detach the sound from the previously attached mesh
  37849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37850. */
  37851. detachFromMesh(): void;
  37852. private _onRegisterAfterWorldMatrixUpdate;
  37853. /**
  37854. * Clone the current sound in the scene.
  37855. * @returns the new sound clone
  37856. */
  37857. clone(): Nullable<Sound>;
  37858. /**
  37859. * Gets the current underlying audio buffer containing the data
  37860. * @returns the audio buffer
  37861. */
  37862. getAudioBuffer(): Nullable<AudioBuffer>;
  37863. /**
  37864. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37865. * @returns the source node
  37866. */
  37867. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37868. /**
  37869. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37870. * @returns the gain node
  37871. */
  37872. getSoundGain(): Nullable<GainNode>;
  37873. /**
  37874. * Serializes the Sound in a JSON representation
  37875. * @returns the JSON representation of the sound
  37876. */
  37877. serialize(): any;
  37878. /**
  37879. * Parse a JSON representation of a sound to innstantiate in a given scene
  37880. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37881. * @param scene Define the scene the new parsed sound should be created in
  37882. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37883. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37884. * @returns the newly parsed sound
  37885. */
  37886. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37887. }
  37888. }
  37889. declare module BABYLON {
  37890. /**
  37891. * This defines an action helpful to play a defined sound on a triggered action.
  37892. */
  37893. export class PlaySoundAction extends Action {
  37894. private _sound;
  37895. /**
  37896. * Instantiate the action
  37897. * @param triggerOptions defines the trigger options
  37898. * @param sound defines the sound to play
  37899. * @param condition defines the trigger related conditions
  37900. */
  37901. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37902. /** @hidden */
  37903. _prepare(): void;
  37904. /**
  37905. * Execute the action and play the sound.
  37906. */
  37907. execute(): void;
  37908. /**
  37909. * Serializes the actions and its related information.
  37910. * @param parent defines the object to serialize in
  37911. * @returns the serialized object
  37912. */
  37913. serialize(parent: any): any;
  37914. }
  37915. /**
  37916. * This defines an action helpful to stop a defined sound on a triggered action.
  37917. */
  37918. export class StopSoundAction extends Action {
  37919. private _sound;
  37920. /**
  37921. * Instantiate the action
  37922. * @param triggerOptions defines the trigger options
  37923. * @param sound defines the sound to stop
  37924. * @param condition defines the trigger related conditions
  37925. */
  37926. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37927. /** @hidden */
  37928. _prepare(): void;
  37929. /**
  37930. * Execute the action and stop the sound.
  37931. */
  37932. execute(): void;
  37933. /**
  37934. * Serializes the actions and its related information.
  37935. * @param parent defines the object to serialize in
  37936. * @returns the serialized object
  37937. */
  37938. serialize(parent: any): any;
  37939. }
  37940. }
  37941. declare module BABYLON {
  37942. /**
  37943. * This defines an action responsible to change the value of a property
  37944. * by interpolating between its current value and the newly set one once triggered.
  37945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37946. */
  37947. export class InterpolateValueAction extends Action {
  37948. /**
  37949. * Defines the path of the property where the value should be interpolated
  37950. */
  37951. propertyPath: string;
  37952. /**
  37953. * Defines the target value at the end of the interpolation.
  37954. */
  37955. value: any;
  37956. /**
  37957. * Defines the time it will take for the property to interpolate to the value.
  37958. */
  37959. duration: number;
  37960. /**
  37961. * Defines if the other scene animations should be stopped when the action has been triggered
  37962. */
  37963. stopOtherAnimations?: boolean;
  37964. /**
  37965. * Defines a callback raised once the interpolation animation has been done.
  37966. */
  37967. onInterpolationDone?: () => void;
  37968. /**
  37969. * Observable triggered once the interpolation animation has been done.
  37970. */
  37971. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37972. private _target;
  37973. private _effectiveTarget;
  37974. private _property;
  37975. /**
  37976. * Instantiate the action
  37977. * @param triggerOptions defines the trigger options
  37978. * @param target defines the object containing the value to interpolate
  37979. * @param propertyPath defines the path to the property in the target object
  37980. * @param value defines the target value at the end of the interpolation
  37981. * @param duration deines the time it will take for the property to interpolate to the value.
  37982. * @param condition defines the trigger related conditions
  37983. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37984. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37985. */
  37986. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37987. /** @hidden */
  37988. _prepare(): void;
  37989. /**
  37990. * Execute the action starts the value interpolation.
  37991. */
  37992. execute(): void;
  37993. /**
  37994. * Serializes the actions and its related information.
  37995. * @param parent defines the object to serialize in
  37996. * @returns the serialized object
  37997. */
  37998. serialize(parent: any): any;
  37999. }
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * Options allowed during the creation of a sound track.
  38004. */
  38005. export interface ISoundTrackOptions {
  38006. /**
  38007. * The volume the sound track should take during creation
  38008. */
  38009. volume?: number;
  38010. /**
  38011. * Define if the sound track is the main sound track of the scene
  38012. */
  38013. mainTrack?: boolean;
  38014. }
  38015. /**
  38016. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38017. * It will be also used in a future release to apply effects on a specific track.
  38018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38019. */
  38020. export class SoundTrack {
  38021. /**
  38022. * The unique identifier of the sound track in the scene.
  38023. */
  38024. id: number;
  38025. /**
  38026. * The list of sounds included in the sound track.
  38027. */
  38028. soundCollection: Array<Sound>;
  38029. private _outputAudioNode;
  38030. private _scene;
  38031. private _connectedAnalyser;
  38032. private _options;
  38033. private _isInitialized;
  38034. /**
  38035. * Creates a new sound track.
  38036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38037. * @param scene Define the scene the sound track belongs to
  38038. * @param options
  38039. */
  38040. constructor(scene: Scene, options?: ISoundTrackOptions);
  38041. private _initializeSoundTrackAudioGraph;
  38042. /**
  38043. * Release the sound track and its associated resources
  38044. */
  38045. dispose(): void;
  38046. /**
  38047. * Adds a sound to this sound track
  38048. * @param sound define the cound to add
  38049. * @ignoreNaming
  38050. */
  38051. AddSound(sound: Sound): void;
  38052. /**
  38053. * Removes a sound to this sound track
  38054. * @param sound define the cound to remove
  38055. * @ignoreNaming
  38056. */
  38057. RemoveSound(sound: Sound): void;
  38058. /**
  38059. * Set a global volume for the full sound track.
  38060. * @param newVolume Define the new volume of the sound track
  38061. */
  38062. setVolume(newVolume: number): void;
  38063. /**
  38064. * Switch the panning model to HRTF:
  38065. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38067. */
  38068. switchPanningModelToHRTF(): void;
  38069. /**
  38070. * Switch the panning model to Equal Power:
  38071. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38073. */
  38074. switchPanningModelToEqualPower(): void;
  38075. /**
  38076. * Connect the sound track to an audio analyser allowing some amazing
  38077. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38079. * @param analyser The analyser to connect to the engine
  38080. */
  38081. connectToAnalyser(analyser: Analyser): void;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. interface AbstractScene {
  38086. /**
  38087. * The list of sounds used in the scene.
  38088. */
  38089. sounds: Nullable<Array<Sound>>;
  38090. }
  38091. interface Scene {
  38092. /**
  38093. * @hidden
  38094. * Backing field
  38095. */
  38096. _mainSoundTrack: SoundTrack;
  38097. /**
  38098. * The main sound track played by the scene.
  38099. * It cotains your primary collection of sounds.
  38100. */
  38101. mainSoundTrack: SoundTrack;
  38102. /**
  38103. * The list of sound tracks added to the scene
  38104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38105. */
  38106. soundTracks: Nullable<Array<SoundTrack>>;
  38107. /**
  38108. * Gets a sound using a given name
  38109. * @param name defines the name to search for
  38110. * @return the found sound or null if not found at all.
  38111. */
  38112. getSoundByName(name: string): Nullable<Sound>;
  38113. /**
  38114. * Gets or sets if audio support is enabled
  38115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38116. */
  38117. audioEnabled: boolean;
  38118. /**
  38119. * Gets or sets if audio will be output to headphones
  38120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38121. */
  38122. headphone: boolean;
  38123. /**
  38124. * Gets or sets custom audio listener position provider
  38125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38126. */
  38127. audioListenerPositionProvider: Nullable<() => Vector3>;
  38128. /**
  38129. * Gets or sets a refresh rate when using 3D audio positioning
  38130. */
  38131. audioPositioningRefreshRate: number;
  38132. }
  38133. /**
  38134. * Defines the sound scene component responsible to manage any sounds
  38135. * in a given scene.
  38136. */
  38137. export class AudioSceneComponent implements ISceneSerializableComponent {
  38138. /**
  38139. * The component name helpfull to identify the component in the list of scene components.
  38140. */
  38141. readonly name: string;
  38142. /**
  38143. * The scene the component belongs to.
  38144. */
  38145. scene: Scene;
  38146. private _audioEnabled;
  38147. /**
  38148. * Gets whether audio is enabled or not.
  38149. * Please use related enable/disable method to switch state.
  38150. */
  38151. get audioEnabled(): boolean;
  38152. private _headphone;
  38153. /**
  38154. * Gets whether audio is outputing to headphone or not.
  38155. * Please use the according Switch methods to change output.
  38156. */
  38157. get headphone(): boolean;
  38158. /**
  38159. * Gets or sets a refresh rate when using 3D audio positioning
  38160. */
  38161. audioPositioningRefreshRate: number;
  38162. private _audioListenerPositionProvider;
  38163. /**
  38164. * Gets the current audio listener position provider
  38165. */
  38166. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38167. /**
  38168. * Sets a custom listener position for all sounds in the scene
  38169. * By default, this is the position of the first active camera
  38170. */
  38171. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38172. /**
  38173. * Creates a new instance of the component for the given scene
  38174. * @param scene Defines the scene to register the component in
  38175. */
  38176. constructor(scene: Scene);
  38177. /**
  38178. * Registers the component in a given scene
  38179. */
  38180. register(): void;
  38181. /**
  38182. * Rebuilds the elements related to this component in case of
  38183. * context lost for instance.
  38184. */
  38185. rebuild(): void;
  38186. /**
  38187. * Serializes the component data to the specified json object
  38188. * @param serializationObject The object to serialize to
  38189. */
  38190. serialize(serializationObject: any): void;
  38191. /**
  38192. * Adds all the elements from the container to the scene
  38193. * @param container the container holding the elements
  38194. */
  38195. addFromContainer(container: AbstractScene): void;
  38196. /**
  38197. * Removes all the elements in the container from the scene
  38198. * @param container contains the elements to remove
  38199. * @param dispose if the removed element should be disposed (default: false)
  38200. */
  38201. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38202. /**
  38203. * Disposes the component and the associated ressources.
  38204. */
  38205. dispose(): void;
  38206. /**
  38207. * Disables audio in the associated scene.
  38208. */
  38209. disableAudio(): void;
  38210. /**
  38211. * Enables audio in the associated scene.
  38212. */
  38213. enableAudio(): void;
  38214. /**
  38215. * Switch audio to headphone output.
  38216. */
  38217. switchAudioModeForHeadphones(): void;
  38218. /**
  38219. * Switch audio to normal speakers.
  38220. */
  38221. switchAudioModeForNormalSpeakers(): void;
  38222. private _cachedCameraDirection;
  38223. private _cachedCameraPosition;
  38224. private _lastCheck;
  38225. private _afterRender;
  38226. }
  38227. }
  38228. declare module BABYLON {
  38229. /**
  38230. * Wraps one or more Sound objects and selects one with random weight for playback.
  38231. */
  38232. export class WeightedSound {
  38233. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38234. loop: boolean;
  38235. private _coneInnerAngle;
  38236. private _coneOuterAngle;
  38237. private _volume;
  38238. /** A Sound is currently playing. */
  38239. isPlaying: boolean;
  38240. /** A Sound is currently paused. */
  38241. isPaused: boolean;
  38242. private _sounds;
  38243. private _weights;
  38244. private _currentIndex?;
  38245. /**
  38246. * Creates a new WeightedSound from the list of sounds given.
  38247. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38248. * @param sounds Array of Sounds that will be selected from.
  38249. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38250. */
  38251. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38252. /**
  38253. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38254. */
  38255. get directionalConeInnerAngle(): number;
  38256. /**
  38257. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38258. */
  38259. set directionalConeInnerAngle(value: number);
  38260. /**
  38261. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38262. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38263. */
  38264. get directionalConeOuterAngle(): number;
  38265. /**
  38266. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38267. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38268. */
  38269. set directionalConeOuterAngle(value: number);
  38270. /**
  38271. * Playback volume.
  38272. */
  38273. get volume(): number;
  38274. /**
  38275. * Playback volume.
  38276. */
  38277. set volume(value: number);
  38278. private _onended;
  38279. /**
  38280. * Suspend playback
  38281. */
  38282. pause(): void;
  38283. /**
  38284. * Stop playback
  38285. */
  38286. stop(): void;
  38287. /**
  38288. * Start playback.
  38289. * @param startOffset Position the clip head at a specific time in seconds.
  38290. */
  38291. play(startOffset?: number): void;
  38292. }
  38293. }
  38294. declare module BABYLON {
  38295. /**
  38296. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38298. */
  38299. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38300. /**
  38301. * Gets the name of the behavior.
  38302. */
  38303. get name(): string;
  38304. /**
  38305. * The easing function used by animations
  38306. */
  38307. static EasingFunction: BackEase;
  38308. /**
  38309. * The easing mode used by animations
  38310. */
  38311. static EasingMode: number;
  38312. /**
  38313. * The duration of the animation, in milliseconds
  38314. */
  38315. transitionDuration: number;
  38316. /**
  38317. * Length of the distance animated by the transition when lower radius is reached
  38318. */
  38319. lowerRadiusTransitionRange: number;
  38320. /**
  38321. * Length of the distance animated by the transition when upper radius is reached
  38322. */
  38323. upperRadiusTransitionRange: number;
  38324. private _autoTransitionRange;
  38325. /**
  38326. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38327. */
  38328. get autoTransitionRange(): boolean;
  38329. /**
  38330. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38331. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38332. */
  38333. set autoTransitionRange(value: boolean);
  38334. private _attachedCamera;
  38335. private _onAfterCheckInputsObserver;
  38336. private _onMeshTargetChangedObserver;
  38337. /**
  38338. * Initializes the behavior.
  38339. */
  38340. init(): void;
  38341. /**
  38342. * Attaches the behavior to its arc rotate camera.
  38343. * @param camera Defines the camera to attach the behavior to
  38344. */
  38345. attach(camera: ArcRotateCamera): void;
  38346. /**
  38347. * Detaches the behavior from its current arc rotate camera.
  38348. */
  38349. detach(): void;
  38350. private _radiusIsAnimating;
  38351. private _radiusBounceTransition;
  38352. private _animatables;
  38353. private _cachedWheelPrecision;
  38354. /**
  38355. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38356. * @param radiusLimit The limit to check against.
  38357. * @return Bool to indicate if at limit.
  38358. */
  38359. private _isRadiusAtLimit;
  38360. /**
  38361. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38362. * @param radiusDelta The delta by which to animate to. Can be negative.
  38363. */
  38364. private _applyBoundRadiusAnimation;
  38365. /**
  38366. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38367. */
  38368. protected _clearAnimationLocks(): void;
  38369. /**
  38370. * Stops and removes all animations that have been applied to the camera
  38371. */
  38372. stopAllAnimations(): void;
  38373. }
  38374. }
  38375. declare module BABYLON {
  38376. /**
  38377. * 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.
  38378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38379. */
  38380. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38381. /**
  38382. * Gets the name of the behavior.
  38383. */
  38384. get name(): string;
  38385. private _mode;
  38386. private _radiusScale;
  38387. private _positionScale;
  38388. private _defaultElevation;
  38389. private _elevationReturnTime;
  38390. private _elevationReturnWaitTime;
  38391. private _zoomStopsAnimation;
  38392. private _framingTime;
  38393. /**
  38394. * The easing function used by animations
  38395. */
  38396. static EasingFunction: ExponentialEase;
  38397. /**
  38398. * The easing mode used by animations
  38399. */
  38400. static EasingMode: number;
  38401. /**
  38402. * Sets the current mode used by the behavior
  38403. */
  38404. set mode(mode: number);
  38405. /**
  38406. * Gets current mode used by the behavior.
  38407. */
  38408. get mode(): number;
  38409. /**
  38410. * Sets the scale applied to the radius (1 by default)
  38411. */
  38412. set radiusScale(radius: number);
  38413. /**
  38414. * Gets the scale applied to the radius
  38415. */
  38416. get radiusScale(): number;
  38417. /**
  38418. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38419. */
  38420. set positionScale(scale: number);
  38421. /**
  38422. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38423. */
  38424. get positionScale(): number;
  38425. /**
  38426. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38427. * behaviour is triggered, in radians.
  38428. */
  38429. set defaultElevation(elevation: number);
  38430. /**
  38431. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38432. * behaviour is triggered, in radians.
  38433. */
  38434. get defaultElevation(): number;
  38435. /**
  38436. * Sets the time (in milliseconds) taken to return to the default beta position.
  38437. * Negative value indicates camera should not return to default.
  38438. */
  38439. set elevationReturnTime(speed: number);
  38440. /**
  38441. * Gets the time (in milliseconds) taken to return to the default beta position.
  38442. * Negative value indicates camera should not return to default.
  38443. */
  38444. get elevationReturnTime(): number;
  38445. /**
  38446. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38447. */
  38448. set elevationReturnWaitTime(time: number);
  38449. /**
  38450. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38451. */
  38452. get elevationReturnWaitTime(): number;
  38453. /**
  38454. * Sets the flag that indicates if user zooming should stop animation.
  38455. */
  38456. set zoomStopsAnimation(flag: boolean);
  38457. /**
  38458. * Gets the flag that indicates if user zooming should stop animation.
  38459. */
  38460. get zoomStopsAnimation(): boolean;
  38461. /**
  38462. * Sets the transition time when framing the mesh, in milliseconds
  38463. */
  38464. set framingTime(time: number);
  38465. /**
  38466. * Gets the transition time when framing the mesh, in milliseconds
  38467. */
  38468. get framingTime(): number;
  38469. /**
  38470. * Define if the behavior should automatically change the configured
  38471. * camera limits and sensibilities.
  38472. */
  38473. autoCorrectCameraLimitsAndSensibility: boolean;
  38474. private _onPrePointerObservableObserver;
  38475. private _onAfterCheckInputsObserver;
  38476. private _onMeshTargetChangedObserver;
  38477. private _attachedCamera;
  38478. private _isPointerDown;
  38479. private _lastInteractionTime;
  38480. /**
  38481. * Initializes the behavior.
  38482. */
  38483. init(): void;
  38484. /**
  38485. * Attaches the behavior to its arc rotate camera.
  38486. * @param camera Defines the camera to attach the behavior to
  38487. */
  38488. attach(camera: ArcRotateCamera): void;
  38489. /**
  38490. * Detaches the behavior from its current arc rotate camera.
  38491. */
  38492. detach(): void;
  38493. private _animatables;
  38494. private _betaIsAnimating;
  38495. private _betaTransition;
  38496. private _radiusTransition;
  38497. private _vectorTransition;
  38498. /**
  38499. * Targets the given mesh and updates zoom level accordingly.
  38500. * @param mesh The mesh to target.
  38501. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38502. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38503. */
  38504. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38505. /**
  38506. * Targets the given mesh with its children and updates zoom level accordingly.
  38507. * @param mesh The mesh to target.
  38508. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38509. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38510. */
  38511. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38512. /**
  38513. * Targets the given meshes with their children and updates zoom level accordingly.
  38514. * @param meshes The mesh to target.
  38515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38517. */
  38518. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38519. /**
  38520. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38521. * @param minimumWorld Determines the smaller position of the bounding box extend
  38522. * @param maximumWorld Determines the bigger position of the bounding box extend
  38523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38525. */
  38526. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38527. /**
  38528. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38529. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38530. * frustum width.
  38531. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38532. * to fully enclose the mesh in the viewing frustum.
  38533. */
  38534. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38535. /**
  38536. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38537. * is automatically returned to its default position (expected to be above ground plane).
  38538. */
  38539. private _maintainCameraAboveGround;
  38540. /**
  38541. * Returns the frustum slope based on the canvas ratio and camera FOV
  38542. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38543. */
  38544. private _getFrustumSlope;
  38545. /**
  38546. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38547. */
  38548. private _clearAnimationLocks;
  38549. /**
  38550. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38551. */
  38552. private _applyUserInteraction;
  38553. /**
  38554. * Stops and removes all animations that have been applied to the camera
  38555. */
  38556. stopAllAnimations(): void;
  38557. /**
  38558. * Gets a value indicating if the user is moving the camera
  38559. */
  38560. get isUserIsMoving(): boolean;
  38561. /**
  38562. * The camera can move all the way towards the mesh.
  38563. */
  38564. static IgnoreBoundsSizeMode: number;
  38565. /**
  38566. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38567. */
  38568. static FitFrustumSidesMode: number;
  38569. }
  38570. }
  38571. declare module BABYLON {
  38572. /**
  38573. * Base class for Camera Pointer Inputs.
  38574. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38575. * for example usage.
  38576. */
  38577. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38578. /**
  38579. * Defines the camera the input is attached to.
  38580. */
  38581. abstract camera: Camera;
  38582. /**
  38583. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38584. */
  38585. protected _altKey: boolean;
  38586. protected _ctrlKey: boolean;
  38587. protected _metaKey: boolean;
  38588. protected _shiftKey: boolean;
  38589. /**
  38590. * Which mouse buttons were pressed at time of last mouse event.
  38591. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38592. */
  38593. protected _buttonsPressed: number;
  38594. /**
  38595. * Defines the buttons associated with the input to handle camera move.
  38596. */
  38597. buttons: number[];
  38598. /**
  38599. * Attach the input controls to a specific dom element to get the input from.
  38600. * @param element Defines the element the controls should be listened from
  38601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38602. */
  38603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38604. /**
  38605. * Detach the current controls from the specified dom element.
  38606. * @param element Defines the element to stop listening the inputs from
  38607. */
  38608. detachControl(element: Nullable<HTMLElement>): void;
  38609. /**
  38610. * Gets the class name of the current input.
  38611. * @returns the class name
  38612. */
  38613. getClassName(): string;
  38614. /**
  38615. * Get the friendly name associated with the input class.
  38616. * @returns the input friendly name
  38617. */
  38618. getSimpleName(): string;
  38619. /**
  38620. * Called on pointer POINTERDOUBLETAP event.
  38621. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38622. */
  38623. protected onDoubleTap(type: string): void;
  38624. /**
  38625. * Called on pointer POINTERMOVE event if only a single touch is active.
  38626. * Override this method to provide functionality.
  38627. */
  38628. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38629. /**
  38630. * Called on pointer POINTERMOVE event if multiple touches are active.
  38631. * Override this method to provide functionality.
  38632. */
  38633. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38634. /**
  38635. * Called on JS contextmenu event.
  38636. * Override this method to provide functionality.
  38637. */
  38638. protected onContextMenu(evt: PointerEvent): void;
  38639. /**
  38640. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38641. * press.
  38642. * Override this method to provide functionality.
  38643. */
  38644. protected onButtonDown(evt: PointerEvent): void;
  38645. /**
  38646. * Called each time a new POINTERUP event occurs. Ie, for each button
  38647. * release.
  38648. * Override this method to provide functionality.
  38649. */
  38650. protected onButtonUp(evt: PointerEvent): void;
  38651. /**
  38652. * Called when window becomes inactive.
  38653. * Override this method to provide functionality.
  38654. */
  38655. protected onLostFocus(): void;
  38656. private _pointerInput;
  38657. private _observer;
  38658. private _onLostFocus;
  38659. private pointA;
  38660. private pointB;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /**
  38665. * Manage the pointers inputs to control an arc rotate camera.
  38666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38667. */
  38668. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38669. /**
  38670. * Defines the camera the input is attached to.
  38671. */
  38672. camera: ArcRotateCamera;
  38673. /**
  38674. * Gets the class name of the current input.
  38675. * @returns the class name
  38676. */
  38677. getClassName(): string;
  38678. /**
  38679. * Defines the buttons associated with the input to handle camera move.
  38680. */
  38681. buttons: number[];
  38682. /**
  38683. * Defines the pointer angular sensibility along the X axis or how fast is
  38684. * the camera rotating.
  38685. */
  38686. angularSensibilityX: number;
  38687. /**
  38688. * Defines the pointer angular sensibility along the Y axis or how fast is
  38689. * the camera rotating.
  38690. */
  38691. angularSensibilityY: number;
  38692. /**
  38693. * Defines the pointer pinch precision or how fast is the camera zooming.
  38694. */
  38695. pinchPrecision: number;
  38696. /**
  38697. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38698. * from 0.
  38699. * It defines the percentage of current camera.radius to use as delta when
  38700. * pinch zoom is used.
  38701. */
  38702. pinchDeltaPercentage: number;
  38703. /**
  38704. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38705. * that any object in the plane at the camera's target point will scale
  38706. * perfectly with finger motion.
  38707. * Overrides pinchDeltaPercentage and pinchPrecision.
  38708. */
  38709. useNaturalPinchZoom: boolean;
  38710. /**
  38711. * Defines the pointer panning sensibility or how fast is the camera moving.
  38712. */
  38713. panningSensibility: number;
  38714. /**
  38715. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38716. */
  38717. multiTouchPanning: boolean;
  38718. /**
  38719. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38720. * zoom (pinch) through multitouch.
  38721. */
  38722. multiTouchPanAndZoom: boolean;
  38723. /**
  38724. * Revers pinch action direction.
  38725. */
  38726. pinchInwards: boolean;
  38727. private _isPanClick;
  38728. private _twoFingerActivityCount;
  38729. private _isPinching;
  38730. /**
  38731. * Called on pointer POINTERMOVE event if only a single touch is active.
  38732. */
  38733. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38734. /**
  38735. * Called on pointer POINTERDOUBLETAP event.
  38736. */
  38737. protected onDoubleTap(type: string): void;
  38738. /**
  38739. * Called on pointer POINTERMOVE event if multiple touches are active.
  38740. */
  38741. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38742. /**
  38743. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38744. * press.
  38745. */
  38746. protected onButtonDown(evt: PointerEvent): void;
  38747. /**
  38748. * Called each time a new POINTERUP event occurs. Ie, for each button
  38749. * release.
  38750. */
  38751. protected onButtonUp(evt: PointerEvent): void;
  38752. /**
  38753. * Called when window becomes inactive.
  38754. */
  38755. protected onLostFocus(): void;
  38756. }
  38757. }
  38758. declare module BABYLON {
  38759. /**
  38760. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38762. */
  38763. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38764. /**
  38765. * Defines the camera the input is attached to.
  38766. */
  38767. camera: ArcRotateCamera;
  38768. /**
  38769. * Defines the list of key codes associated with the up action (increase alpha)
  38770. */
  38771. keysUp: number[];
  38772. /**
  38773. * Defines the list of key codes associated with the down action (decrease alpha)
  38774. */
  38775. keysDown: number[];
  38776. /**
  38777. * Defines the list of key codes associated with the left action (increase beta)
  38778. */
  38779. keysLeft: number[];
  38780. /**
  38781. * Defines the list of key codes associated with the right action (decrease beta)
  38782. */
  38783. keysRight: number[];
  38784. /**
  38785. * Defines the list of key codes associated with the reset action.
  38786. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38787. */
  38788. keysReset: number[];
  38789. /**
  38790. * Defines the panning sensibility of the inputs.
  38791. * (How fast is the camera panning)
  38792. */
  38793. panningSensibility: number;
  38794. /**
  38795. * Defines the zooming sensibility of the inputs.
  38796. * (How fast is the camera zooming)
  38797. */
  38798. zoomingSensibility: number;
  38799. /**
  38800. * Defines whether maintaining the alt key down switch the movement mode from
  38801. * orientation to zoom.
  38802. */
  38803. useAltToZoom: boolean;
  38804. /**
  38805. * Rotation speed of the camera
  38806. */
  38807. angularSpeed: number;
  38808. private _keys;
  38809. private _ctrlPressed;
  38810. private _altPressed;
  38811. private _onCanvasBlurObserver;
  38812. private _onKeyboardObserver;
  38813. private _engine;
  38814. private _scene;
  38815. /**
  38816. * Attach the input controls to a specific dom element to get the input from.
  38817. * @param element Defines the element the controls should be listened from
  38818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38819. */
  38820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38821. /**
  38822. * Detach the current controls from the specified dom element.
  38823. * @param element Defines the element to stop listening the inputs from
  38824. */
  38825. detachControl(element: Nullable<HTMLElement>): void;
  38826. /**
  38827. * Update the current camera state depending on the inputs that have been used this frame.
  38828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38829. */
  38830. checkInputs(): void;
  38831. /**
  38832. * Gets the class name of the current intput.
  38833. * @returns the class name
  38834. */
  38835. getClassName(): string;
  38836. /**
  38837. * Get the friendly name associated with the input class.
  38838. * @returns the input friendly name
  38839. */
  38840. getSimpleName(): string;
  38841. }
  38842. }
  38843. declare module BABYLON {
  38844. /**
  38845. * Manage the mouse wheel inputs to control an arc rotate camera.
  38846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38847. */
  38848. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38849. /**
  38850. * Defines the camera the input is attached to.
  38851. */
  38852. camera: ArcRotateCamera;
  38853. /**
  38854. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38855. */
  38856. wheelPrecision: number;
  38857. /**
  38858. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38859. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38860. */
  38861. wheelDeltaPercentage: number;
  38862. private _wheel;
  38863. private _observer;
  38864. private computeDeltaFromMouseWheelLegacyEvent;
  38865. /**
  38866. * Attach the input controls to a specific dom element to get the input from.
  38867. * @param element Defines the element the controls should be listened from
  38868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38869. */
  38870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38871. /**
  38872. * Detach the current controls from the specified dom element.
  38873. * @param element Defines the element to stop listening the inputs from
  38874. */
  38875. detachControl(element: Nullable<HTMLElement>): void;
  38876. /**
  38877. * Gets the class name of the current intput.
  38878. * @returns the class name
  38879. */
  38880. getClassName(): string;
  38881. /**
  38882. * Get the friendly name associated with the input class.
  38883. * @returns the input friendly name
  38884. */
  38885. getSimpleName(): string;
  38886. }
  38887. }
  38888. declare module BABYLON {
  38889. /**
  38890. * Default Inputs manager for the ArcRotateCamera.
  38891. * It groups all the default supported inputs for ease of use.
  38892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38893. */
  38894. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38895. /**
  38896. * Instantiates a new ArcRotateCameraInputsManager.
  38897. * @param camera Defines the camera the inputs belong to
  38898. */
  38899. constructor(camera: ArcRotateCamera);
  38900. /**
  38901. * Add mouse wheel input support to the input manager.
  38902. * @returns the current input manager
  38903. */
  38904. addMouseWheel(): ArcRotateCameraInputsManager;
  38905. /**
  38906. * Add pointers input support to the input manager.
  38907. * @returns the current input manager
  38908. */
  38909. addPointers(): ArcRotateCameraInputsManager;
  38910. /**
  38911. * Add keyboard input support to the input manager.
  38912. * @returns the current input manager
  38913. */
  38914. addKeyboard(): ArcRotateCameraInputsManager;
  38915. }
  38916. }
  38917. declare module BABYLON {
  38918. /**
  38919. * This represents an orbital type of camera.
  38920. *
  38921. * 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.
  38922. * 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.
  38923. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38924. */
  38925. export class ArcRotateCamera extends TargetCamera {
  38926. /**
  38927. * Defines the rotation angle of the camera along the longitudinal axis.
  38928. */
  38929. alpha: number;
  38930. /**
  38931. * Defines the rotation angle of the camera along the latitudinal axis.
  38932. */
  38933. beta: number;
  38934. /**
  38935. * Defines the radius of the camera from it s target point.
  38936. */
  38937. radius: number;
  38938. protected _target: Vector3;
  38939. protected _targetHost: Nullable<AbstractMesh>;
  38940. /**
  38941. * Defines the target point of the camera.
  38942. * The camera looks towards it form the radius distance.
  38943. */
  38944. get target(): Vector3;
  38945. set target(value: Vector3);
  38946. /**
  38947. * Define the current local position of the camera in the scene
  38948. */
  38949. get position(): Vector3;
  38950. set position(newPosition: Vector3);
  38951. protected _upVector: Vector3;
  38952. protected _upToYMatrix: Matrix;
  38953. protected _YToUpMatrix: Matrix;
  38954. /**
  38955. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38956. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38957. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38958. */
  38959. set upVector(vec: Vector3);
  38960. get upVector(): Vector3;
  38961. /**
  38962. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38963. */
  38964. setMatUp(): void;
  38965. /**
  38966. * Current inertia value on the longitudinal axis.
  38967. * The bigger this number the longer it will take for the camera to stop.
  38968. */
  38969. inertialAlphaOffset: number;
  38970. /**
  38971. * Current inertia value on the latitudinal axis.
  38972. * The bigger this number the longer it will take for the camera to stop.
  38973. */
  38974. inertialBetaOffset: number;
  38975. /**
  38976. * Current inertia value on the radius axis.
  38977. * The bigger this number the longer it will take for the camera to stop.
  38978. */
  38979. inertialRadiusOffset: number;
  38980. /**
  38981. * Minimum allowed angle on the longitudinal axis.
  38982. * This can help limiting how the Camera is able to move in the scene.
  38983. */
  38984. lowerAlphaLimit: Nullable<number>;
  38985. /**
  38986. * Maximum allowed angle on the longitudinal axis.
  38987. * This can help limiting how the Camera is able to move in the scene.
  38988. */
  38989. upperAlphaLimit: Nullable<number>;
  38990. /**
  38991. * Minimum allowed angle on the latitudinal axis.
  38992. * This can help limiting how the Camera is able to move in the scene.
  38993. */
  38994. lowerBetaLimit: number;
  38995. /**
  38996. * Maximum allowed angle on the latitudinal axis.
  38997. * This can help limiting how the Camera is able to move in the scene.
  38998. */
  38999. upperBetaLimit: number;
  39000. /**
  39001. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39002. * This can help limiting how the Camera is able to move in the scene.
  39003. */
  39004. lowerRadiusLimit: Nullable<number>;
  39005. /**
  39006. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39007. * This can help limiting how the Camera is able to move in the scene.
  39008. */
  39009. upperRadiusLimit: Nullable<number>;
  39010. /**
  39011. * Defines the current inertia value used during panning of the camera along the X axis.
  39012. */
  39013. inertialPanningX: number;
  39014. /**
  39015. * Defines the current inertia value used during panning of the camera along the Y axis.
  39016. */
  39017. inertialPanningY: number;
  39018. /**
  39019. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39020. * Basically if your fingers moves away from more than this distance you will be considered
  39021. * in pinch mode.
  39022. */
  39023. pinchToPanMaxDistance: number;
  39024. /**
  39025. * Defines the maximum distance the camera can pan.
  39026. * This could help keeping the cammera always in your scene.
  39027. */
  39028. panningDistanceLimit: Nullable<number>;
  39029. /**
  39030. * Defines the target of the camera before paning.
  39031. */
  39032. panningOriginTarget: Vector3;
  39033. /**
  39034. * Defines the value of the inertia used during panning.
  39035. * 0 would mean stop inertia and one would mean no decelleration at all.
  39036. */
  39037. panningInertia: number;
  39038. /**
  39039. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39040. */
  39041. get angularSensibilityX(): number;
  39042. set angularSensibilityX(value: number);
  39043. /**
  39044. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39045. */
  39046. get angularSensibilityY(): number;
  39047. set angularSensibilityY(value: number);
  39048. /**
  39049. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39050. */
  39051. get pinchPrecision(): number;
  39052. set pinchPrecision(value: number);
  39053. /**
  39054. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39055. * It will be used instead of pinchDeltaPrecision if different from 0.
  39056. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39057. */
  39058. get pinchDeltaPercentage(): number;
  39059. set pinchDeltaPercentage(value: number);
  39060. /**
  39061. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39062. * and pinch delta percentage.
  39063. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39064. * that any object in the plane at the camera's target point will scale
  39065. * perfectly with finger motion.
  39066. */
  39067. get useNaturalPinchZoom(): boolean;
  39068. set useNaturalPinchZoom(value: boolean);
  39069. /**
  39070. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39071. */
  39072. get panningSensibility(): number;
  39073. set panningSensibility(value: number);
  39074. /**
  39075. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39076. */
  39077. get keysUp(): number[];
  39078. set keysUp(value: number[]);
  39079. /**
  39080. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39081. */
  39082. get keysDown(): number[];
  39083. set keysDown(value: number[]);
  39084. /**
  39085. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39086. */
  39087. get keysLeft(): number[];
  39088. set keysLeft(value: number[]);
  39089. /**
  39090. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39091. */
  39092. get keysRight(): number[];
  39093. set keysRight(value: number[]);
  39094. /**
  39095. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39096. */
  39097. get wheelPrecision(): number;
  39098. set wheelPrecision(value: number);
  39099. /**
  39100. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39101. * It will be used instead of pinchDeltaPrecision if different from 0.
  39102. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39103. */
  39104. get wheelDeltaPercentage(): number;
  39105. set wheelDeltaPercentage(value: number);
  39106. /**
  39107. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39108. */
  39109. zoomOnFactor: number;
  39110. /**
  39111. * Defines a screen offset for the camera position.
  39112. */
  39113. targetScreenOffset: Vector2;
  39114. /**
  39115. * Allows the camera to be completely reversed.
  39116. * If false the camera can not arrive upside down.
  39117. */
  39118. allowUpsideDown: boolean;
  39119. /**
  39120. * Define if double tap/click is used to restore the previously saved state of the camera.
  39121. */
  39122. useInputToRestoreState: boolean;
  39123. /** @hidden */
  39124. _viewMatrix: Matrix;
  39125. /** @hidden */
  39126. _useCtrlForPanning: boolean;
  39127. /** @hidden */
  39128. _panningMouseButton: number;
  39129. /**
  39130. * Defines the input associated to the camera.
  39131. */
  39132. inputs: ArcRotateCameraInputsManager;
  39133. /** @hidden */
  39134. _reset: () => void;
  39135. /**
  39136. * Defines the allowed panning axis.
  39137. */
  39138. panningAxis: Vector3;
  39139. protected _localDirection: Vector3;
  39140. protected _transformedDirection: Vector3;
  39141. private _bouncingBehavior;
  39142. /**
  39143. * Gets the bouncing behavior of the camera if it has been enabled.
  39144. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39145. */
  39146. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39147. /**
  39148. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39150. */
  39151. get useBouncingBehavior(): boolean;
  39152. set useBouncingBehavior(value: boolean);
  39153. private _framingBehavior;
  39154. /**
  39155. * Gets the framing behavior of the camera if it has been enabled.
  39156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39157. */
  39158. get framingBehavior(): Nullable<FramingBehavior>;
  39159. /**
  39160. * Defines if the framing behavior of the camera is enabled on the camera.
  39161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39162. */
  39163. get useFramingBehavior(): boolean;
  39164. set useFramingBehavior(value: boolean);
  39165. private _autoRotationBehavior;
  39166. /**
  39167. * Gets the auto rotation behavior of the camera if it has been enabled.
  39168. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39169. */
  39170. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39171. /**
  39172. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39174. */
  39175. get useAutoRotationBehavior(): boolean;
  39176. set useAutoRotationBehavior(value: boolean);
  39177. /**
  39178. * Observable triggered when the mesh target has been changed on the camera.
  39179. */
  39180. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39181. /**
  39182. * Event raised when the camera is colliding with a mesh.
  39183. */
  39184. onCollide: (collidedMesh: AbstractMesh) => void;
  39185. /**
  39186. * Defines whether the camera should check collision with the objects oh the scene.
  39187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39188. */
  39189. checkCollisions: boolean;
  39190. /**
  39191. * Defines the collision radius of the camera.
  39192. * This simulates a sphere around the camera.
  39193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39194. */
  39195. collisionRadius: Vector3;
  39196. protected _collider: Collider;
  39197. protected _previousPosition: Vector3;
  39198. protected _collisionVelocity: Vector3;
  39199. protected _newPosition: Vector3;
  39200. protected _previousAlpha: number;
  39201. protected _previousBeta: number;
  39202. protected _previousRadius: number;
  39203. protected _collisionTriggered: boolean;
  39204. protected _targetBoundingCenter: Nullable<Vector3>;
  39205. private _computationVector;
  39206. /**
  39207. * Instantiates a new ArcRotateCamera in a given scene
  39208. * @param name Defines the name of the camera
  39209. * @param alpha Defines the camera rotation along the logitudinal axis
  39210. * @param beta Defines the camera rotation along the latitudinal axis
  39211. * @param radius Defines the camera distance from its target
  39212. * @param target Defines the camera target
  39213. * @param scene Defines the scene the camera belongs to
  39214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39215. */
  39216. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39217. /** @hidden */
  39218. _initCache(): void;
  39219. /** @hidden */
  39220. _updateCache(ignoreParentClass?: boolean): void;
  39221. protected _getTargetPosition(): Vector3;
  39222. private _storedAlpha;
  39223. private _storedBeta;
  39224. private _storedRadius;
  39225. private _storedTarget;
  39226. private _storedTargetScreenOffset;
  39227. /**
  39228. * Stores the current state of the camera (alpha, beta, radius and target)
  39229. * @returns the camera itself
  39230. */
  39231. storeState(): Camera;
  39232. /**
  39233. * @hidden
  39234. * Restored camera state. You must call storeState() first
  39235. */
  39236. _restoreStateValues(): boolean;
  39237. /** @hidden */
  39238. _isSynchronizedViewMatrix(): boolean;
  39239. /**
  39240. * Attached controls to the current camera.
  39241. * @param element Defines the element the controls should be listened from
  39242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39243. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39244. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39245. */
  39246. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39247. /**
  39248. * Detach the current controls from the camera.
  39249. * The camera will stop reacting to inputs.
  39250. * @param element Defines the element to stop listening the inputs from
  39251. */
  39252. detachControl(element: HTMLElement): void;
  39253. /** @hidden */
  39254. _checkInputs(): void;
  39255. protected _checkLimits(): void;
  39256. /**
  39257. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39258. */
  39259. rebuildAnglesAndRadius(): void;
  39260. /**
  39261. * Use a position to define the current camera related information like alpha, beta and radius
  39262. * @param position Defines the position to set the camera at
  39263. */
  39264. setPosition(position: Vector3): void;
  39265. /**
  39266. * Defines the target the camera should look at.
  39267. * This will automatically adapt alpha beta and radius to fit within the new target.
  39268. * @param target Defines the new target as a Vector or a mesh
  39269. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39270. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39271. */
  39272. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39273. /** @hidden */
  39274. _getViewMatrix(): Matrix;
  39275. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39276. /**
  39277. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39278. * @param meshes Defines the mesh to zoom on
  39279. * @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)
  39280. */
  39281. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39282. /**
  39283. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39284. * The target will be changed but the radius
  39285. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39286. * @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)
  39287. */
  39288. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39289. min: Vector3;
  39290. max: Vector3;
  39291. distance: number;
  39292. }, doNotUpdateMaxZ?: boolean): void;
  39293. /**
  39294. * @override
  39295. * Override Camera.createRigCamera
  39296. */
  39297. createRigCamera(name: string, cameraIndex: number): Camera;
  39298. /**
  39299. * @hidden
  39300. * @override
  39301. * Override Camera._updateRigCameras
  39302. */
  39303. _updateRigCameras(): void;
  39304. /**
  39305. * Destroy the camera and release the current resources hold by it.
  39306. */
  39307. dispose(): void;
  39308. /**
  39309. * Gets the current object class name.
  39310. * @return the class name
  39311. */
  39312. getClassName(): string;
  39313. }
  39314. }
  39315. declare module BABYLON {
  39316. /**
  39317. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39319. */
  39320. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39321. /**
  39322. * Gets the name of the behavior.
  39323. */
  39324. get name(): string;
  39325. private _zoomStopsAnimation;
  39326. private _idleRotationSpeed;
  39327. private _idleRotationWaitTime;
  39328. private _idleRotationSpinupTime;
  39329. /**
  39330. * Sets the flag that indicates if user zooming should stop animation.
  39331. */
  39332. set zoomStopsAnimation(flag: boolean);
  39333. /**
  39334. * Gets the flag that indicates if user zooming should stop animation.
  39335. */
  39336. get zoomStopsAnimation(): boolean;
  39337. /**
  39338. * Sets the default speed at which the camera rotates around the model.
  39339. */
  39340. set idleRotationSpeed(speed: number);
  39341. /**
  39342. * Gets the default speed at which the camera rotates around the model.
  39343. */
  39344. get idleRotationSpeed(): number;
  39345. /**
  39346. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39347. */
  39348. set idleRotationWaitTime(time: number);
  39349. /**
  39350. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39351. */
  39352. get idleRotationWaitTime(): number;
  39353. /**
  39354. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39355. */
  39356. set idleRotationSpinupTime(time: number);
  39357. /**
  39358. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39359. */
  39360. get idleRotationSpinupTime(): number;
  39361. /**
  39362. * Gets a value indicating if the camera is currently rotating because of this behavior
  39363. */
  39364. get rotationInProgress(): boolean;
  39365. private _onPrePointerObservableObserver;
  39366. private _onAfterCheckInputsObserver;
  39367. private _attachedCamera;
  39368. private _isPointerDown;
  39369. private _lastFrameTime;
  39370. private _lastInteractionTime;
  39371. private _cameraRotationSpeed;
  39372. /**
  39373. * Initializes the behavior.
  39374. */
  39375. init(): void;
  39376. /**
  39377. * Attaches the behavior to its arc rotate camera.
  39378. * @param camera Defines the camera to attach the behavior to
  39379. */
  39380. attach(camera: ArcRotateCamera): void;
  39381. /**
  39382. * Detaches the behavior from its current arc rotate camera.
  39383. */
  39384. detach(): void;
  39385. /**
  39386. * Returns true if user is scrolling.
  39387. * @return true if user is scrolling.
  39388. */
  39389. private _userIsZooming;
  39390. private _lastFrameRadius;
  39391. private _shouldAnimationStopForInteraction;
  39392. /**
  39393. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39394. */
  39395. private _applyUserInteraction;
  39396. private _userIsMoving;
  39397. }
  39398. }
  39399. declare module BABYLON {
  39400. /**
  39401. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39402. */
  39403. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39404. private ui;
  39405. /**
  39406. * The name of the behavior
  39407. */
  39408. name: string;
  39409. /**
  39410. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39411. */
  39412. distanceAwayFromFace: number;
  39413. /**
  39414. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39415. */
  39416. distanceAwayFromBottomOfFace: number;
  39417. private _faceVectors;
  39418. private _target;
  39419. private _scene;
  39420. private _onRenderObserver;
  39421. private _tmpMatrix;
  39422. private _tmpVector;
  39423. /**
  39424. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39425. * @param ui The transform node that should be attched to the mesh
  39426. */
  39427. constructor(ui: TransformNode);
  39428. /**
  39429. * Initializes the behavior
  39430. */
  39431. init(): void;
  39432. private _closestFace;
  39433. private _zeroVector;
  39434. private _lookAtTmpMatrix;
  39435. private _lookAtToRef;
  39436. /**
  39437. * Attaches the AttachToBoxBehavior to the passed in mesh
  39438. * @param target The mesh that the specified node will be attached to
  39439. */
  39440. attach(target: Mesh): void;
  39441. /**
  39442. * Detaches the behavior from the mesh
  39443. */
  39444. detach(): void;
  39445. }
  39446. }
  39447. declare module BABYLON {
  39448. /**
  39449. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39450. */
  39451. export class FadeInOutBehavior implements Behavior<Mesh> {
  39452. /**
  39453. * Time in milliseconds to delay before fading in (Default: 0)
  39454. */
  39455. delay: number;
  39456. /**
  39457. * Time in milliseconds for the mesh to fade in (Default: 300)
  39458. */
  39459. fadeInTime: number;
  39460. private _millisecondsPerFrame;
  39461. private _hovered;
  39462. private _hoverValue;
  39463. private _ownerNode;
  39464. /**
  39465. * Instatiates the FadeInOutBehavior
  39466. */
  39467. constructor();
  39468. /**
  39469. * The name of the behavior
  39470. */
  39471. get name(): string;
  39472. /**
  39473. * Initializes the behavior
  39474. */
  39475. init(): void;
  39476. /**
  39477. * Attaches the fade behavior on the passed in mesh
  39478. * @param ownerNode The mesh that will be faded in/out once attached
  39479. */
  39480. attach(ownerNode: Mesh): void;
  39481. /**
  39482. * Detaches the behavior from the mesh
  39483. */
  39484. detach(): void;
  39485. /**
  39486. * Triggers the mesh to begin fading in or out
  39487. * @param value if the object should fade in or out (true to fade in)
  39488. */
  39489. fadeIn(value: boolean): void;
  39490. private _update;
  39491. private _setAllVisibility;
  39492. }
  39493. }
  39494. declare module BABYLON {
  39495. /**
  39496. * Class containing a set of static utilities functions for managing Pivots
  39497. * @hidden
  39498. */
  39499. export class PivotTools {
  39500. private static _PivotCached;
  39501. private static _OldPivotPoint;
  39502. private static _PivotTranslation;
  39503. private static _PivotTmpVector;
  39504. /** @hidden */
  39505. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39506. /** @hidden */
  39507. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39508. }
  39509. }
  39510. declare module BABYLON {
  39511. /**
  39512. * Class containing static functions to help procedurally build meshes
  39513. */
  39514. export class PlaneBuilder {
  39515. /**
  39516. * Creates a plane mesh
  39517. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39518. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39519. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39521. * * 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
  39522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39523. * @param name defines the name of the mesh
  39524. * @param options defines the options used to create the mesh
  39525. * @param scene defines the hosting scene
  39526. * @returns the plane mesh
  39527. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39528. */
  39529. static CreatePlane(name: string, options: {
  39530. size?: number;
  39531. width?: number;
  39532. height?: number;
  39533. sideOrientation?: number;
  39534. frontUVs?: Vector4;
  39535. backUVs?: Vector4;
  39536. updatable?: boolean;
  39537. sourcePlane?: Plane;
  39538. }, scene?: Nullable<Scene>): Mesh;
  39539. }
  39540. }
  39541. declare module BABYLON {
  39542. /**
  39543. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39544. */
  39545. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39546. private static _AnyMouseID;
  39547. /**
  39548. * Abstract mesh the behavior is set on
  39549. */
  39550. attachedNode: AbstractMesh;
  39551. private _dragPlane;
  39552. private _scene;
  39553. private _pointerObserver;
  39554. private _beforeRenderObserver;
  39555. private static _planeScene;
  39556. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39557. /**
  39558. * 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)
  39559. */
  39560. maxDragAngle: number;
  39561. /**
  39562. * @hidden
  39563. */
  39564. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39565. /**
  39566. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39567. */
  39568. currentDraggingPointerID: number;
  39569. /**
  39570. * The last position where the pointer hit the drag plane in world space
  39571. */
  39572. lastDragPosition: Vector3;
  39573. /**
  39574. * If the behavior is currently in a dragging state
  39575. */
  39576. dragging: boolean;
  39577. /**
  39578. * 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)
  39579. */
  39580. dragDeltaRatio: number;
  39581. /**
  39582. * If the drag plane orientation should be updated during the dragging (Default: true)
  39583. */
  39584. updateDragPlane: boolean;
  39585. private _debugMode;
  39586. private _moving;
  39587. /**
  39588. * Fires each time the attached mesh is dragged with the pointer
  39589. * * delta between last drag position and current drag position in world space
  39590. * * dragDistance along the drag axis
  39591. * * dragPlaneNormal normal of the current drag plane used during the drag
  39592. * * dragPlanePoint in world space where the drag intersects the drag plane
  39593. */
  39594. onDragObservable: Observable<{
  39595. delta: Vector3;
  39596. dragPlanePoint: Vector3;
  39597. dragPlaneNormal: Vector3;
  39598. dragDistance: number;
  39599. pointerId: number;
  39600. }>;
  39601. /**
  39602. * Fires each time a drag begins (eg. mouse down on mesh)
  39603. */
  39604. onDragStartObservable: Observable<{
  39605. dragPlanePoint: Vector3;
  39606. pointerId: number;
  39607. }>;
  39608. /**
  39609. * Fires each time a drag ends (eg. mouse release after drag)
  39610. */
  39611. onDragEndObservable: Observable<{
  39612. dragPlanePoint: Vector3;
  39613. pointerId: number;
  39614. }>;
  39615. /**
  39616. * If the attached mesh should be moved when dragged
  39617. */
  39618. moveAttached: boolean;
  39619. /**
  39620. * If the drag behavior will react to drag events (Default: true)
  39621. */
  39622. enabled: boolean;
  39623. /**
  39624. * If pointer events should start and release the drag (Default: true)
  39625. */
  39626. startAndReleaseDragOnPointerEvents: boolean;
  39627. /**
  39628. * If camera controls should be detached during the drag
  39629. */
  39630. detachCameraControls: boolean;
  39631. /**
  39632. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39633. */
  39634. useObjectOrientationForDragging: boolean;
  39635. private _options;
  39636. /**
  39637. * Gets the options used by the behavior
  39638. */
  39639. get options(): {
  39640. dragAxis?: Vector3;
  39641. dragPlaneNormal?: Vector3;
  39642. };
  39643. /**
  39644. * Sets the options used by the behavior
  39645. */
  39646. set options(options: {
  39647. dragAxis?: Vector3;
  39648. dragPlaneNormal?: Vector3;
  39649. });
  39650. /**
  39651. * Creates a pointer drag behavior that can be attached to a mesh
  39652. * @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)
  39653. */
  39654. constructor(options?: {
  39655. dragAxis?: Vector3;
  39656. dragPlaneNormal?: Vector3;
  39657. });
  39658. /**
  39659. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39660. */
  39661. validateDrag: (targetPosition: Vector3) => boolean;
  39662. /**
  39663. * The name of the behavior
  39664. */
  39665. get name(): string;
  39666. /**
  39667. * Initializes the behavior
  39668. */
  39669. init(): void;
  39670. private _tmpVector;
  39671. private _alternatePickedPoint;
  39672. private _worldDragAxis;
  39673. private _targetPosition;
  39674. private _attachedElement;
  39675. /**
  39676. * Attaches the drag behavior the passed in mesh
  39677. * @param ownerNode The mesh that will be dragged around once attached
  39678. * @param predicate Predicate to use for pick filtering
  39679. */
  39680. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39681. /**
  39682. * Force relase the drag action by code.
  39683. */
  39684. releaseDrag(): void;
  39685. private _startDragRay;
  39686. private _lastPointerRay;
  39687. /**
  39688. * Simulates the start of a pointer drag event on the behavior
  39689. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39690. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39691. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39692. */
  39693. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39694. private _startDrag;
  39695. private _dragDelta;
  39696. private _moveDrag;
  39697. private _pickWithRayOnDragPlane;
  39698. private _pointA;
  39699. private _pointB;
  39700. private _pointC;
  39701. private _lineA;
  39702. private _lineB;
  39703. private _localAxis;
  39704. private _lookAt;
  39705. private _updateDragPlanePosition;
  39706. /**
  39707. * Detaches the behavior from the mesh
  39708. */
  39709. detach(): void;
  39710. }
  39711. }
  39712. declare module BABYLON {
  39713. /**
  39714. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39715. */
  39716. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39717. private _dragBehaviorA;
  39718. private _dragBehaviorB;
  39719. private _startDistance;
  39720. private _initialScale;
  39721. private _targetScale;
  39722. private _ownerNode;
  39723. private _sceneRenderObserver;
  39724. /**
  39725. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39726. */
  39727. constructor();
  39728. /**
  39729. * The name of the behavior
  39730. */
  39731. get name(): string;
  39732. /**
  39733. * Initializes the behavior
  39734. */
  39735. init(): void;
  39736. private _getCurrentDistance;
  39737. /**
  39738. * Attaches the scale behavior the passed in mesh
  39739. * @param ownerNode The mesh that will be scaled around once attached
  39740. */
  39741. attach(ownerNode: Mesh): void;
  39742. /**
  39743. * Detaches the behavior from the mesh
  39744. */
  39745. detach(): void;
  39746. }
  39747. }
  39748. declare module BABYLON {
  39749. /**
  39750. * 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
  39751. */
  39752. export class SixDofDragBehavior implements Behavior<Mesh> {
  39753. private static _virtualScene;
  39754. private _ownerNode;
  39755. private _sceneRenderObserver;
  39756. private _scene;
  39757. private _targetPosition;
  39758. private _virtualOriginMesh;
  39759. private _virtualDragMesh;
  39760. private _pointerObserver;
  39761. private _moving;
  39762. private _startingOrientation;
  39763. private _attachedElement;
  39764. /**
  39765. * 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)
  39766. */
  39767. private zDragFactor;
  39768. /**
  39769. * If the object should rotate to face the drag origin
  39770. */
  39771. rotateDraggedObject: boolean;
  39772. /**
  39773. * If the behavior is currently in a dragging state
  39774. */
  39775. dragging: boolean;
  39776. /**
  39777. * 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)
  39778. */
  39779. dragDeltaRatio: number;
  39780. /**
  39781. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39782. */
  39783. currentDraggingPointerID: number;
  39784. /**
  39785. * If camera controls should be detached during the drag
  39786. */
  39787. detachCameraControls: boolean;
  39788. /**
  39789. * Fires each time a drag starts
  39790. */
  39791. onDragStartObservable: Observable<{}>;
  39792. /**
  39793. * Fires each time a drag ends (eg. mouse release after drag)
  39794. */
  39795. onDragEndObservable: Observable<{}>;
  39796. /**
  39797. * 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
  39798. */
  39799. constructor();
  39800. /**
  39801. * The name of the behavior
  39802. */
  39803. get name(): string;
  39804. /**
  39805. * Initializes the behavior
  39806. */
  39807. init(): void;
  39808. /**
  39809. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39810. */
  39811. private get _pointerCamera();
  39812. /**
  39813. * Attaches the scale behavior the passed in mesh
  39814. * @param ownerNode The mesh that will be scaled around once attached
  39815. */
  39816. attach(ownerNode: Mesh): void;
  39817. /**
  39818. * Detaches the behavior from the mesh
  39819. */
  39820. detach(): void;
  39821. }
  39822. }
  39823. declare module BABYLON {
  39824. /**
  39825. * Class used to apply inverse kinematics to bones
  39826. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39827. */
  39828. export class BoneIKController {
  39829. private static _tmpVecs;
  39830. private static _tmpQuat;
  39831. private static _tmpMats;
  39832. /**
  39833. * Gets or sets the target mesh
  39834. */
  39835. targetMesh: AbstractMesh;
  39836. /** Gets or sets the mesh used as pole */
  39837. poleTargetMesh: AbstractMesh;
  39838. /**
  39839. * Gets or sets the bone used as pole
  39840. */
  39841. poleTargetBone: Nullable<Bone>;
  39842. /**
  39843. * Gets or sets the target position
  39844. */
  39845. targetPosition: Vector3;
  39846. /**
  39847. * Gets or sets the pole target position
  39848. */
  39849. poleTargetPosition: Vector3;
  39850. /**
  39851. * Gets or sets the pole target local offset
  39852. */
  39853. poleTargetLocalOffset: Vector3;
  39854. /**
  39855. * Gets or sets the pole angle
  39856. */
  39857. poleAngle: number;
  39858. /**
  39859. * Gets or sets the mesh associated with the controller
  39860. */
  39861. mesh: AbstractMesh;
  39862. /**
  39863. * 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)
  39864. */
  39865. slerpAmount: number;
  39866. private _bone1Quat;
  39867. private _bone1Mat;
  39868. private _bone2Ang;
  39869. private _bone1;
  39870. private _bone2;
  39871. private _bone1Length;
  39872. private _bone2Length;
  39873. private _maxAngle;
  39874. private _maxReach;
  39875. private _rightHandedSystem;
  39876. private _bendAxis;
  39877. private _slerping;
  39878. private _adjustRoll;
  39879. /**
  39880. * Gets or sets maximum allowed angle
  39881. */
  39882. get maxAngle(): number;
  39883. set maxAngle(value: number);
  39884. /**
  39885. * Creates a new BoneIKController
  39886. * @param mesh defines the mesh to control
  39887. * @param bone defines the bone to control
  39888. * @param options defines options to set up the controller
  39889. */
  39890. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39891. targetMesh?: AbstractMesh;
  39892. poleTargetMesh?: AbstractMesh;
  39893. poleTargetBone?: Bone;
  39894. poleTargetLocalOffset?: Vector3;
  39895. poleAngle?: number;
  39896. bendAxis?: Vector3;
  39897. maxAngle?: number;
  39898. slerpAmount?: number;
  39899. });
  39900. private _setMaxAngle;
  39901. /**
  39902. * Force the controller to update the bones
  39903. */
  39904. update(): void;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. /**
  39909. * Class used to make a bone look toward a point in space
  39910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39911. */
  39912. export class BoneLookController {
  39913. private static _tmpVecs;
  39914. private static _tmpQuat;
  39915. private static _tmpMats;
  39916. /**
  39917. * The target Vector3 that the bone will look at
  39918. */
  39919. target: Vector3;
  39920. /**
  39921. * The mesh that the bone is attached to
  39922. */
  39923. mesh: AbstractMesh;
  39924. /**
  39925. * The bone that will be looking to the target
  39926. */
  39927. bone: Bone;
  39928. /**
  39929. * The up axis of the coordinate system that is used when the bone is rotated
  39930. */
  39931. upAxis: Vector3;
  39932. /**
  39933. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39934. */
  39935. upAxisSpace: Space;
  39936. /**
  39937. * Used to make an adjustment to the yaw of the bone
  39938. */
  39939. adjustYaw: number;
  39940. /**
  39941. * Used to make an adjustment to the pitch of the bone
  39942. */
  39943. adjustPitch: number;
  39944. /**
  39945. * Used to make an adjustment to the roll of the bone
  39946. */
  39947. adjustRoll: number;
  39948. /**
  39949. * 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)
  39950. */
  39951. slerpAmount: number;
  39952. private _minYaw;
  39953. private _maxYaw;
  39954. private _minPitch;
  39955. private _maxPitch;
  39956. private _minYawSin;
  39957. private _minYawCos;
  39958. private _maxYawSin;
  39959. private _maxYawCos;
  39960. private _midYawConstraint;
  39961. private _minPitchTan;
  39962. private _maxPitchTan;
  39963. private _boneQuat;
  39964. private _slerping;
  39965. private _transformYawPitch;
  39966. private _transformYawPitchInv;
  39967. private _firstFrameSkipped;
  39968. private _yawRange;
  39969. private _fowardAxis;
  39970. /**
  39971. * Gets or sets the minimum yaw angle that the bone can look to
  39972. */
  39973. get minYaw(): number;
  39974. set minYaw(value: number);
  39975. /**
  39976. * Gets or sets the maximum yaw angle that the bone can look to
  39977. */
  39978. get maxYaw(): number;
  39979. set maxYaw(value: number);
  39980. /**
  39981. * Gets or sets the minimum pitch angle that the bone can look to
  39982. */
  39983. get minPitch(): number;
  39984. set minPitch(value: number);
  39985. /**
  39986. * Gets or sets the maximum pitch angle that the bone can look to
  39987. */
  39988. get maxPitch(): number;
  39989. set maxPitch(value: number);
  39990. /**
  39991. * Create a BoneLookController
  39992. * @param mesh the mesh that the bone belongs to
  39993. * @param bone the bone that will be looking to the target
  39994. * @param target the target Vector3 to look at
  39995. * @param options optional settings:
  39996. * * maxYaw: the maximum angle the bone will yaw to
  39997. * * minYaw: the minimum angle the bone will yaw to
  39998. * * maxPitch: the maximum angle the bone will pitch to
  39999. * * minPitch: the minimum angle the bone will yaw to
  40000. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40001. * * upAxis: the up axis of the coordinate system
  40002. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40003. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40004. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40005. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40006. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40007. * * adjustRoll: used to make an adjustment to the roll of the bone
  40008. **/
  40009. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40010. maxYaw?: number;
  40011. minYaw?: number;
  40012. maxPitch?: number;
  40013. minPitch?: number;
  40014. slerpAmount?: number;
  40015. upAxis?: Vector3;
  40016. upAxisSpace?: Space;
  40017. yawAxis?: Vector3;
  40018. pitchAxis?: Vector3;
  40019. adjustYaw?: number;
  40020. adjustPitch?: number;
  40021. adjustRoll?: number;
  40022. });
  40023. /**
  40024. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40025. */
  40026. update(): void;
  40027. private _getAngleDiff;
  40028. private _getAngleBetween;
  40029. private _isAngleBetween;
  40030. }
  40031. }
  40032. declare module BABYLON {
  40033. /**
  40034. * Manage the gamepad inputs to control an arc rotate camera.
  40035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40036. */
  40037. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40038. /**
  40039. * Defines the camera the input is attached to.
  40040. */
  40041. camera: ArcRotateCamera;
  40042. /**
  40043. * Defines the gamepad the input is gathering event from.
  40044. */
  40045. gamepad: Nullable<Gamepad>;
  40046. /**
  40047. * Defines the gamepad rotation sensiblity.
  40048. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40049. */
  40050. gamepadRotationSensibility: number;
  40051. /**
  40052. * Defines the gamepad move sensiblity.
  40053. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40054. */
  40055. gamepadMoveSensibility: number;
  40056. private _yAxisScale;
  40057. /**
  40058. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40059. */
  40060. get invertYAxis(): boolean;
  40061. set invertYAxis(value: boolean);
  40062. private _onGamepadConnectedObserver;
  40063. private _onGamepadDisconnectedObserver;
  40064. /**
  40065. * Attach the input controls to a specific dom element to get the input from.
  40066. * @param element Defines the element the controls should be listened from
  40067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40068. */
  40069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40070. /**
  40071. * Detach the current controls from the specified dom element.
  40072. * @param element Defines the element to stop listening the inputs from
  40073. */
  40074. detachControl(element: Nullable<HTMLElement>): void;
  40075. /**
  40076. * Update the current camera state depending on the inputs that have been used this frame.
  40077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40078. */
  40079. checkInputs(): void;
  40080. /**
  40081. * Gets the class name of the current intput.
  40082. * @returns the class name
  40083. */
  40084. getClassName(): string;
  40085. /**
  40086. * Get the friendly name associated with the input class.
  40087. * @returns the input friendly name
  40088. */
  40089. getSimpleName(): string;
  40090. }
  40091. }
  40092. declare module BABYLON {
  40093. interface ArcRotateCameraInputsManager {
  40094. /**
  40095. * Add orientation input support to the input manager.
  40096. * @returns the current input manager
  40097. */
  40098. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40099. }
  40100. /**
  40101. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40103. */
  40104. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40105. /**
  40106. * Defines the camera the input is attached to.
  40107. */
  40108. camera: ArcRotateCamera;
  40109. /**
  40110. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40111. */
  40112. alphaCorrection: number;
  40113. /**
  40114. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40115. */
  40116. gammaCorrection: number;
  40117. private _alpha;
  40118. private _gamma;
  40119. private _dirty;
  40120. private _deviceOrientationHandler;
  40121. /**
  40122. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40123. */
  40124. constructor();
  40125. /**
  40126. * Attach the input controls to a specific dom element to get the input from.
  40127. * @param element Defines the element the controls should be listened from
  40128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40129. */
  40130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40131. /** @hidden */
  40132. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40133. /**
  40134. * Update the current camera state depending on the inputs that have been used this frame.
  40135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40136. */
  40137. checkInputs(): void;
  40138. /**
  40139. * Detach the current controls from the specified dom element.
  40140. * @param element Defines the element to stop listening the inputs from
  40141. */
  40142. detachControl(element: Nullable<HTMLElement>): void;
  40143. /**
  40144. * Gets the class name of the current intput.
  40145. * @returns the class name
  40146. */
  40147. getClassName(): string;
  40148. /**
  40149. * Get the friendly name associated with the input class.
  40150. * @returns the input friendly name
  40151. */
  40152. getSimpleName(): string;
  40153. }
  40154. }
  40155. declare module BABYLON {
  40156. /**
  40157. * Listen to mouse events to control the camera.
  40158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40159. */
  40160. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40161. /**
  40162. * Defines the camera the input is attached to.
  40163. */
  40164. camera: FlyCamera;
  40165. /**
  40166. * Defines if touch is enabled. (Default is true.)
  40167. */
  40168. touchEnabled: boolean;
  40169. /**
  40170. * Defines the buttons associated with the input to handle camera rotation.
  40171. */
  40172. buttons: number[];
  40173. /**
  40174. * Assign buttons for Yaw control.
  40175. */
  40176. buttonsYaw: number[];
  40177. /**
  40178. * Assign buttons for Pitch control.
  40179. */
  40180. buttonsPitch: number[];
  40181. /**
  40182. * Assign buttons for Roll control.
  40183. */
  40184. buttonsRoll: number[];
  40185. /**
  40186. * Detect if any button is being pressed while mouse is moved.
  40187. * -1 = Mouse locked.
  40188. * 0 = Left button.
  40189. * 1 = Middle Button.
  40190. * 2 = Right Button.
  40191. */
  40192. activeButton: number;
  40193. /**
  40194. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40195. * Higher values reduce its sensitivity.
  40196. */
  40197. angularSensibility: number;
  40198. private _mousemoveCallback;
  40199. private _observer;
  40200. private _rollObserver;
  40201. private previousPosition;
  40202. private noPreventDefault;
  40203. private element;
  40204. /**
  40205. * Listen to mouse events to control the camera.
  40206. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40208. */
  40209. constructor(touchEnabled?: boolean);
  40210. /**
  40211. * Attach the mouse control to the HTML DOM element.
  40212. * @param element Defines the element that listens to the input events.
  40213. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40214. */
  40215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40216. /**
  40217. * Detach the current controls from the specified dom element.
  40218. * @param element Defines the element to stop listening the inputs from
  40219. */
  40220. detachControl(element: Nullable<HTMLElement>): void;
  40221. /**
  40222. * Gets the class name of the current input.
  40223. * @returns the class name.
  40224. */
  40225. getClassName(): string;
  40226. /**
  40227. * Get the friendly name associated with the input class.
  40228. * @returns the input's friendly name.
  40229. */
  40230. getSimpleName(): string;
  40231. private _pointerInput;
  40232. private _onMouseMove;
  40233. /**
  40234. * Rotate camera by mouse offset.
  40235. */
  40236. private rotateCamera;
  40237. }
  40238. }
  40239. declare module BABYLON {
  40240. /**
  40241. * Default Inputs manager for the FlyCamera.
  40242. * It groups all the default supported inputs for ease of use.
  40243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40244. */
  40245. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40246. /**
  40247. * Instantiates a new FlyCameraInputsManager.
  40248. * @param camera Defines the camera the inputs belong to.
  40249. */
  40250. constructor(camera: FlyCamera);
  40251. /**
  40252. * Add keyboard input support to the input manager.
  40253. * @returns the new FlyCameraKeyboardMoveInput().
  40254. */
  40255. addKeyboard(): FlyCameraInputsManager;
  40256. /**
  40257. * Add mouse input support to the input manager.
  40258. * @param touchEnabled Enable touch screen support.
  40259. * @returns the new FlyCameraMouseInput().
  40260. */
  40261. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40262. }
  40263. }
  40264. declare module BABYLON {
  40265. /**
  40266. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40267. * such as in a 3D Space Shooter or a Flight Simulator.
  40268. */
  40269. export class FlyCamera extends TargetCamera {
  40270. /**
  40271. * Define the collision ellipsoid of the camera.
  40272. * This is helpful for simulating a camera body, like a player's body.
  40273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40274. */
  40275. ellipsoid: Vector3;
  40276. /**
  40277. * Define an offset for the position of the ellipsoid around the camera.
  40278. * This can be helpful if the camera is attached away from the player's body center,
  40279. * such as at its head.
  40280. */
  40281. ellipsoidOffset: Vector3;
  40282. /**
  40283. * Enable or disable collisions of the camera with the rest of the scene objects.
  40284. */
  40285. checkCollisions: boolean;
  40286. /**
  40287. * Enable or disable gravity on the camera.
  40288. */
  40289. applyGravity: boolean;
  40290. /**
  40291. * Define the current direction the camera is moving to.
  40292. */
  40293. cameraDirection: Vector3;
  40294. /**
  40295. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40296. * This overrides and empties cameraRotation.
  40297. */
  40298. rotationQuaternion: Quaternion;
  40299. /**
  40300. * Track Roll to maintain the wanted Rolling when looking around.
  40301. */
  40302. _trackRoll: number;
  40303. /**
  40304. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40305. */
  40306. rollCorrect: number;
  40307. /**
  40308. * Mimic a banked turn, Rolling the camera when Yawing.
  40309. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40310. */
  40311. bankedTurn: boolean;
  40312. /**
  40313. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40314. */
  40315. bankedTurnLimit: number;
  40316. /**
  40317. * Value of 0 disables the banked Roll.
  40318. * Value of 1 is equal to the Yaw angle in radians.
  40319. */
  40320. bankedTurnMultiplier: number;
  40321. /**
  40322. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40323. */
  40324. inputs: FlyCameraInputsManager;
  40325. /**
  40326. * Gets the input sensibility for mouse input.
  40327. * Higher values reduce sensitivity.
  40328. */
  40329. get angularSensibility(): number;
  40330. /**
  40331. * Sets the input sensibility for a mouse input.
  40332. * Higher values reduce sensitivity.
  40333. */
  40334. set angularSensibility(value: number);
  40335. /**
  40336. * Get the keys for camera movement forward.
  40337. */
  40338. get keysForward(): number[];
  40339. /**
  40340. * Set the keys for camera movement forward.
  40341. */
  40342. set keysForward(value: number[]);
  40343. /**
  40344. * Get the keys for camera movement backward.
  40345. */
  40346. get keysBackward(): number[];
  40347. set keysBackward(value: number[]);
  40348. /**
  40349. * Get the keys for camera movement up.
  40350. */
  40351. get keysUp(): number[];
  40352. /**
  40353. * Set the keys for camera movement up.
  40354. */
  40355. set keysUp(value: number[]);
  40356. /**
  40357. * Get the keys for camera movement down.
  40358. */
  40359. get keysDown(): number[];
  40360. /**
  40361. * Set the keys for camera movement down.
  40362. */
  40363. set keysDown(value: number[]);
  40364. /**
  40365. * Get the keys for camera movement left.
  40366. */
  40367. get keysLeft(): number[];
  40368. /**
  40369. * Set the keys for camera movement left.
  40370. */
  40371. set keysLeft(value: number[]);
  40372. /**
  40373. * Set the keys for camera movement right.
  40374. */
  40375. get keysRight(): number[];
  40376. /**
  40377. * Set the keys for camera movement right.
  40378. */
  40379. set keysRight(value: number[]);
  40380. /**
  40381. * Event raised when the camera collides with a mesh in the scene.
  40382. */
  40383. onCollide: (collidedMesh: AbstractMesh) => void;
  40384. private _collider;
  40385. private _needMoveForGravity;
  40386. private _oldPosition;
  40387. private _diffPosition;
  40388. private _newPosition;
  40389. /** @hidden */
  40390. _localDirection: Vector3;
  40391. /** @hidden */
  40392. _transformedDirection: Vector3;
  40393. /**
  40394. * Instantiates a FlyCamera.
  40395. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40396. * such as in a 3D Space Shooter or a Flight Simulator.
  40397. * @param name Define the name of the camera in the scene.
  40398. * @param position Define the starting position of the camera in the scene.
  40399. * @param scene Define the scene the camera belongs to.
  40400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40401. */
  40402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40403. /**
  40404. * Attach a control to the HTML DOM element.
  40405. * @param element Defines the element that listens to the input events.
  40406. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40407. */
  40408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40409. /**
  40410. * Detach a control from the HTML DOM element.
  40411. * The camera will stop reacting to that input.
  40412. * @param element Defines the element that listens to the input events.
  40413. */
  40414. detachControl(element: HTMLElement): void;
  40415. private _collisionMask;
  40416. /**
  40417. * Get the mask that the camera ignores in collision events.
  40418. */
  40419. get collisionMask(): number;
  40420. /**
  40421. * Set the mask that the camera ignores in collision events.
  40422. */
  40423. set collisionMask(mask: number);
  40424. /** @hidden */
  40425. _collideWithWorld(displacement: Vector3): void;
  40426. /** @hidden */
  40427. private _onCollisionPositionChange;
  40428. /** @hidden */
  40429. _checkInputs(): void;
  40430. /** @hidden */
  40431. _decideIfNeedsToMove(): boolean;
  40432. /** @hidden */
  40433. _updatePosition(): void;
  40434. /**
  40435. * Restore the Roll to its target value at the rate specified.
  40436. * @param rate - Higher means slower restoring.
  40437. * @hidden
  40438. */
  40439. restoreRoll(rate: number): void;
  40440. /**
  40441. * Destroy the camera and release the current resources held by it.
  40442. */
  40443. dispose(): void;
  40444. /**
  40445. * Get the current object class name.
  40446. * @returns the class name.
  40447. */
  40448. getClassName(): string;
  40449. }
  40450. }
  40451. declare module BABYLON {
  40452. /**
  40453. * Listen to keyboard events to control the camera.
  40454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40455. */
  40456. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40457. /**
  40458. * Defines the camera the input is attached to.
  40459. */
  40460. camera: FlyCamera;
  40461. /**
  40462. * The list of keyboard keys used to control the forward move of the camera.
  40463. */
  40464. keysForward: number[];
  40465. /**
  40466. * The list of keyboard keys used to control the backward move of the camera.
  40467. */
  40468. keysBackward: number[];
  40469. /**
  40470. * The list of keyboard keys used to control the forward move of the camera.
  40471. */
  40472. keysUp: number[];
  40473. /**
  40474. * The list of keyboard keys used to control the backward move of the camera.
  40475. */
  40476. keysDown: number[];
  40477. /**
  40478. * The list of keyboard keys used to control the right strafe move of the camera.
  40479. */
  40480. keysRight: number[];
  40481. /**
  40482. * The list of keyboard keys used to control the left strafe move of the camera.
  40483. */
  40484. keysLeft: number[];
  40485. private _keys;
  40486. private _onCanvasBlurObserver;
  40487. private _onKeyboardObserver;
  40488. private _engine;
  40489. private _scene;
  40490. /**
  40491. * Attach the input controls to a specific dom element to get the input from.
  40492. * @param element Defines the element the controls should be listened from
  40493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40494. */
  40495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40496. /**
  40497. * Detach the current controls from the specified dom element.
  40498. * @param element Defines the element to stop listening the inputs from
  40499. */
  40500. detachControl(element: Nullable<HTMLElement>): void;
  40501. /**
  40502. * Gets the class name of the current intput.
  40503. * @returns the class name
  40504. */
  40505. getClassName(): string;
  40506. /** @hidden */
  40507. _onLostFocus(e: FocusEvent): void;
  40508. /**
  40509. * Get the friendly name associated with the input class.
  40510. * @returns the input friendly name
  40511. */
  40512. getSimpleName(): string;
  40513. /**
  40514. * Update the current camera state depending on the inputs that have been used this frame.
  40515. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40516. */
  40517. checkInputs(): void;
  40518. }
  40519. }
  40520. declare module BABYLON {
  40521. /**
  40522. * Manage the mouse wheel inputs to control a follow camera.
  40523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40524. */
  40525. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40526. /**
  40527. * Defines the camera the input is attached to.
  40528. */
  40529. camera: FollowCamera;
  40530. /**
  40531. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40532. */
  40533. axisControlRadius: boolean;
  40534. /**
  40535. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40536. */
  40537. axisControlHeight: boolean;
  40538. /**
  40539. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40540. */
  40541. axisControlRotation: boolean;
  40542. /**
  40543. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40544. * relation to mouseWheel events.
  40545. */
  40546. wheelPrecision: number;
  40547. /**
  40548. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40549. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40550. */
  40551. wheelDeltaPercentage: number;
  40552. private _wheel;
  40553. private _observer;
  40554. /**
  40555. * Attach the input controls to a specific dom element to get the input from.
  40556. * @param element Defines the element the controls should be listened from
  40557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40558. */
  40559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40560. /**
  40561. * Detach the current controls from the specified dom element.
  40562. * @param element Defines the element to stop listening the inputs from
  40563. */
  40564. detachControl(element: Nullable<HTMLElement>): void;
  40565. /**
  40566. * Gets the class name of the current intput.
  40567. * @returns the class name
  40568. */
  40569. getClassName(): string;
  40570. /**
  40571. * Get the friendly name associated with the input class.
  40572. * @returns the input friendly name
  40573. */
  40574. getSimpleName(): string;
  40575. }
  40576. }
  40577. declare module BABYLON {
  40578. /**
  40579. * Manage the pointers inputs to control an follow camera.
  40580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40581. */
  40582. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40583. /**
  40584. * Defines the camera the input is attached to.
  40585. */
  40586. camera: FollowCamera;
  40587. /**
  40588. * Gets the class name of the current input.
  40589. * @returns the class name
  40590. */
  40591. getClassName(): string;
  40592. /**
  40593. * Defines the pointer angular sensibility along the X axis or how fast is
  40594. * the camera rotating.
  40595. * A negative number will reverse the axis direction.
  40596. */
  40597. angularSensibilityX: number;
  40598. /**
  40599. * Defines the pointer angular sensibility along the Y axis or how fast is
  40600. * the camera rotating.
  40601. * A negative number will reverse the axis direction.
  40602. */
  40603. angularSensibilityY: number;
  40604. /**
  40605. * Defines the pointer pinch precision or how fast is the camera zooming.
  40606. * A negative number will reverse the axis direction.
  40607. */
  40608. pinchPrecision: number;
  40609. /**
  40610. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40611. * from 0.
  40612. * It defines the percentage of current camera.radius to use as delta when
  40613. * pinch zoom is used.
  40614. */
  40615. pinchDeltaPercentage: number;
  40616. /**
  40617. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40618. */
  40619. axisXControlRadius: boolean;
  40620. /**
  40621. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40622. */
  40623. axisXControlHeight: boolean;
  40624. /**
  40625. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40626. */
  40627. axisXControlRotation: boolean;
  40628. /**
  40629. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40630. */
  40631. axisYControlRadius: boolean;
  40632. /**
  40633. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40634. */
  40635. axisYControlHeight: boolean;
  40636. /**
  40637. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40638. */
  40639. axisYControlRotation: boolean;
  40640. /**
  40641. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40642. */
  40643. axisPinchControlRadius: boolean;
  40644. /**
  40645. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40646. */
  40647. axisPinchControlHeight: boolean;
  40648. /**
  40649. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40650. */
  40651. axisPinchControlRotation: boolean;
  40652. /**
  40653. * Log error messages if basic misconfiguration has occurred.
  40654. */
  40655. warningEnable: boolean;
  40656. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40657. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40658. private _warningCounter;
  40659. private _warning;
  40660. }
  40661. }
  40662. declare module BABYLON {
  40663. /**
  40664. * Default Inputs manager for the FollowCamera.
  40665. * It groups all the default supported inputs for ease of use.
  40666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40667. */
  40668. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40669. /**
  40670. * Instantiates a new FollowCameraInputsManager.
  40671. * @param camera Defines the camera the inputs belong to
  40672. */
  40673. constructor(camera: FollowCamera);
  40674. /**
  40675. * Add keyboard input support to the input manager.
  40676. * @returns the current input manager
  40677. */
  40678. addKeyboard(): FollowCameraInputsManager;
  40679. /**
  40680. * Add mouse wheel input support to the input manager.
  40681. * @returns the current input manager
  40682. */
  40683. addMouseWheel(): FollowCameraInputsManager;
  40684. /**
  40685. * Add pointers input support to the input manager.
  40686. * @returns the current input manager
  40687. */
  40688. addPointers(): FollowCameraInputsManager;
  40689. /**
  40690. * Add orientation input support to the input manager.
  40691. * @returns the current input manager
  40692. */
  40693. addVRDeviceOrientation(): FollowCameraInputsManager;
  40694. }
  40695. }
  40696. declare module BABYLON {
  40697. /**
  40698. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40699. * an arc rotate version arcFollowCamera are available.
  40700. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40701. */
  40702. export class FollowCamera extends TargetCamera {
  40703. /**
  40704. * Distance the follow camera should follow an object at
  40705. */
  40706. radius: number;
  40707. /**
  40708. * Minimum allowed distance of the camera to the axis of rotation
  40709. * (The camera can not get closer).
  40710. * This can help limiting how the Camera is able to move in the scene.
  40711. */
  40712. lowerRadiusLimit: Nullable<number>;
  40713. /**
  40714. * Maximum allowed distance of the camera to the axis of rotation
  40715. * (The camera can not get further).
  40716. * This can help limiting how the Camera is able to move in the scene.
  40717. */
  40718. upperRadiusLimit: Nullable<number>;
  40719. /**
  40720. * Define a rotation offset between the camera and the object it follows
  40721. */
  40722. rotationOffset: number;
  40723. /**
  40724. * Minimum allowed angle to camera position relative to target object.
  40725. * This can help limiting how the Camera is able to move in the scene.
  40726. */
  40727. lowerRotationOffsetLimit: Nullable<number>;
  40728. /**
  40729. * Maximum allowed angle to camera position relative to target object.
  40730. * This can help limiting how the Camera is able to move in the scene.
  40731. */
  40732. upperRotationOffsetLimit: Nullable<number>;
  40733. /**
  40734. * Define a height offset between the camera and the object it follows.
  40735. * It can help following an object from the top (like a car chaing a plane)
  40736. */
  40737. heightOffset: number;
  40738. /**
  40739. * Minimum allowed height of camera position relative to target object.
  40740. * This can help limiting how the Camera is able to move in the scene.
  40741. */
  40742. lowerHeightOffsetLimit: Nullable<number>;
  40743. /**
  40744. * Maximum allowed height of camera position relative to target object.
  40745. * This can help limiting how the Camera is able to move in the scene.
  40746. */
  40747. upperHeightOffsetLimit: Nullable<number>;
  40748. /**
  40749. * Define how fast the camera can accelerate to follow it s target.
  40750. */
  40751. cameraAcceleration: number;
  40752. /**
  40753. * Define the speed limit of the camera following an object.
  40754. */
  40755. maxCameraSpeed: number;
  40756. /**
  40757. * Define the target of the camera.
  40758. */
  40759. lockedTarget: Nullable<AbstractMesh>;
  40760. /**
  40761. * Defines the input associated with the camera.
  40762. */
  40763. inputs: FollowCameraInputsManager;
  40764. /**
  40765. * Instantiates the follow camera.
  40766. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40767. * @param name Define the name of the camera in the scene
  40768. * @param position Define the position of the camera
  40769. * @param scene Define the scene the camera belong to
  40770. * @param lockedTarget Define the target of the camera
  40771. */
  40772. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40773. private _follow;
  40774. /**
  40775. * Attached controls to the current camera.
  40776. * @param element Defines the element the controls should be listened from
  40777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40778. */
  40779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40780. /**
  40781. * Detach the current controls from the camera.
  40782. * The camera will stop reacting to inputs.
  40783. * @param element Defines the element to stop listening the inputs from
  40784. */
  40785. detachControl(element: HTMLElement): void;
  40786. /** @hidden */
  40787. _checkInputs(): void;
  40788. private _checkLimits;
  40789. /**
  40790. * Gets the camera class name.
  40791. * @returns the class name
  40792. */
  40793. getClassName(): string;
  40794. }
  40795. /**
  40796. * Arc Rotate version of the follow camera.
  40797. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40798. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40799. */
  40800. export class ArcFollowCamera extends TargetCamera {
  40801. /** The longitudinal angle of the camera */
  40802. alpha: number;
  40803. /** The latitudinal angle of the camera */
  40804. beta: number;
  40805. /** The radius of the camera from its target */
  40806. radius: number;
  40807. /** Define the camera target (the messh it should follow) */
  40808. target: Nullable<AbstractMesh>;
  40809. private _cartesianCoordinates;
  40810. /**
  40811. * Instantiates a new ArcFollowCamera
  40812. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40813. * @param name Define the name of the camera
  40814. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40815. * @param beta Define the rotation angle of the camera around the elevation axis
  40816. * @param radius Define the radius of the camera from its target point
  40817. * @param target Define the target of the camera
  40818. * @param scene Define the scene the camera belongs to
  40819. */
  40820. constructor(name: string,
  40821. /** The longitudinal angle of the camera */
  40822. alpha: number,
  40823. /** The latitudinal angle of the camera */
  40824. beta: number,
  40825. /** The radius of the camera from its target */
  40826. radius: number,
  40827. /** Define the camera target (the messh it should follow) */
  40828. target: Nullable<AbstractMesh>, scene: Scene);
  40829. private _follow;
  40830. /** @hidden */
  40831. _checkInputs(): void;
  40832. /**
  40833. * Returns the class name of the object.
  40834. * It is mostly used internally for serialization purposes.
  40835. */
  40836. getClassName(): string;
  40837. }
  40838. }
  40839. declare module BABYLON {
  40840. /**
  40841. * Manage the keyboard inputs to control the movement of a follow camera.
  40842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40843. */
  40844. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40845. /**
  40846. * Defines the camera the input is attached to.
  40847. */
  40848. camera: FollowCamera;
  40849. /**
  40850. * Defines the list of key codes associated with the up action (increase heightOffset)
  40851. */
  40852. keysHeightOffsetIncr: number[];
  40853. /**
  40854. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40855. */
  40856. keysHeightOffsetDecr: number[];
  40857. /**
  40858. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40859. */
  40860. keysHeightOffsetModifierAlt: boolean;
  40861. /**
  40862. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40863. */
  40864. keysHeightOffsetModifierCtrl: boolean;
  40865. /**
  40866. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40867. */
  40868. keysHeightOffsetModifierShift: boolean;
  40869. /**
  40870. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40871. */
  40872. keysRotationOffsetIncr: number[];
  40873. /**
  40874. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40875. */
  40876. keysRotationOffsetDecr: number[];
  40877. /**
  40878. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40879. */
  40880. keysRotationOffsetModifierAlt: boolean;
  40881. /**
  40882. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40883. */
  40884. keysRotationOffsetModifierCtrl: boolean;
  40885. /**
  40886. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40887. */
  40888. keysRotationOffsetModifierShift: boolean;
  40889. /**
  40890. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40891. */
  40892. keysRadiusIncr: number[];
  40893. /**
  40894. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40895. */
  40896. keysRadiusDecr: number[];
  40897. /**
  40898. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40899. */
  40900. keysRadiusModifierAlt: boolean;
  40901. /**
  40902. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40903. */
  40904. keysRadiusModifierCtrl: boolean;
  40905. /**
  40906. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40907. */
  40908. keysRadiusModifierShift: boolean;
  40909. /**
  40910. * Defines the rate of change of heightOffset.
  40911. */
  40912. heightSensibility: number;
  40913. /**
  40914. * Defines the rate of change of rotationOffset.
  40915. */
  40916. rotationSensibility: number;
  40917. /**
  40918. * Defines the rate of change of radius.
  40919. */
  40920. radiusSensibility: number;
  40921. private _keys;
  40922. private _ctrlPressed;
  40923. private _altPressed;
  40924. private _shiftPressed;
  40925. private _onCanvasBlurObserver;
  40926. private _onKeyboardObserver;
  40927. private _engine;
  40928. private _scene;
  40929. /**
  40930. * Attach the input controls to a specific dom element to get the input from.
  40931. * @param element Defines the element the controls should be listened from
  40932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40933. */
  40934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40935. /**
  40936. * Detach the current controls from the specified dom element.
  40937. * @param element Defines the element to stop listening the inputs from
  40938. */
  40939. detachControl(element: Nullable<HTMLElement>): void;
  40940. /**
  40941. * Update the current camera state depending on the inputs that have been used this frame.
  40942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40943. */
  40944. checkInputs(): void;
  40945. /**
  40946. * Gets the class name of the current input.
  40947. * @returns the class name
  40948. */
  40949. getClassName(): string;
  40950. /**
  40951. * Get the friendly name associated with the input class.
  40952. * @returns the input friendly name
  40953. */
  40954. getSimpleName(): string;
  40955. /**
  40956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40957. * allow modification of the heightOffset value.
  40958. */
  40959. private _modifierHeightOffset;
  40960. /**
  40961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40962. * allow modification of the rotationOffset value.
  40963. */
  40964. private _modifierRotationOffset;
  40965. /**
  40966. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40967. * allow modification of the radius value.
  40968. */
  40969. private _modifierRadius;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. interface FreeCameraInputsManager {
  40974. /**
  40975. * @hidden
  40976. */
  40977. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40978. /**
  40979. * Add orientation input support to the input manager.
  40980. * @returns the current input manager
  40981. */
  40982. addDeviceOrientation(): FreeCameraInputsManager;
  40983. }
  40984. /**
  40985. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40986. * Screen rotation is taken into account.
  40987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40988. */
  40989. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40990. private _camera;
  40991. private _screenOrientationAngle;
  40992. private _constantTranform;
  40993. private _screenQuaternion;
  40994. private _alpha;
  40995. private _beta;
  40996. private _gamma;
  40997. /**
  40998. * Can be used to detect if a device orientation sensor is available on a device
  40999. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41000. * @returns a promise that will resolve on orientation change
  41001. */
  41002. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41003. /**
  41004. * @hidden
  41005. */
  41006. _onDeviceOrientationChangedObservable: Observable<void>;
  41007. /**
  41008. * Instantiates a new input
  41009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41010. */
  41011. constructor();
  41012. /**
  41013. * Define the camera controlled by the input.
  41014. */
  41015. get camera(): FreeCamera;
  41016. set camera(camera: FreeCamera);
  41017. /**
  41018. * Attach the input controls to a specific dom element to get the input from.
  41019. * @param element Defines the element the controls should be listened from
  41020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41021. */
  41022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41023. private _orientationChanged;
  41024. private _deviceOrientation;
  41025. /**
  41026. * Detach the current controls from the specified dom element.
  41027. * @param element Defines the element to stop listening the inputs from
  41028. */
  41029. detachControl(element: Nullable<HTMLElement>): void;
  41030. /**
  41031. * Update the current camera state depending on the inputs that have been used this frame.
  41032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41033. */
  41034. checkInputs(): void;
  41035. /**
  41036. * Gets the class name of the current intput.
  41037. * @returns the class name
  41038. */
  41039. getClassName(): string;
  41040. /**
  41041. * Get the friendly name associated with the input class.
  41042. * @returns the input friendly name
  41043. */
  41044. getSimpleName(): string;
  41045. }
  41046. }
  41047. declare module BABYLON {
  41048. /**
  41049. * Manage the gamepad inputs to control a free camera.
  41050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41051. */
  41052. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41053. /**
  41054. * Define the camera the input is attached to.
  41055. */
  41056. camera: FreeCamera;
  41057. /**
  41058. * Define the Gamepad controlling the input
  41059. */
  41060. gamepad: Nullable<Gamepad>;
  41061. /**
  41062. * Defines the gamepad rotation sensiblity.
  41063. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41064. */
  41065. gamepadAngularSensibility: number;
  41066. /**
  41067. * Defines the gamepad move sensiblity.
  41068. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41069. */
  41070. gamepadMoveSensibility: number;
  41071. private _yAxisScale;
  41072. /**
  41073. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41074. */
  41075. get invertYAxis(): boolean;
  41076. set invertYAxis(value: boolean);
  41077. private _onGamepadConnectedObserver;
  41078. private _onGamepadDisconnectedObserver;
  41079. private _cameraTransform;
  41080. private _deltaTransform;
  41081. private _vector3;
  41082. private _vector2;
  41083. /**
  41084. * Attach the input controls to a specific dom element to get the input from.
  41085. * @param element Defines the element the controls should be listened from
  41086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41087. */
  41088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41089. /**
  41090. * Detach the current controls from the specified dom element.
  41091. * @param element Defines the element to stop listening the inputs from
  41092. */
  41093. detachControl(element: Nullable<HTMLElement>): void;
  41094. /**
  41095. * Update the current camera state depending on the inputs that have been used this frame.
  41096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41097. */
  41098. checkInputs(): void;
  41099. /**
  41100. * Gets the class name of the current intput.
  41101. * @returns the class name
  41102. */
  41103. getClassName(): string;
  41104. /**
  41105. * Get the friendly name associated with the input class.
  41106. * @returns the input friendly name
  41107. */
  41108. getSimpleName(): string;
  41109. }
  41110. }
  41111. declare module BABYLON {
  41112. /**
  41113. * Defines the potential axis of a Joystick
  41114. */
  41115. export enum JoystickAxis {
  41116. /** X axis */
  41117. X = 0,
  41118. /** Y axis */
  41119. Y = 1,
  41120. /** Z axis */
  41121. Z = 2
  41122. }
  41123. /**
  41124. * Class used to define virtual joystick (used in touch mode)
  41125. */
  41126. export class VirtualJoystick {
  41127. /**
  41128. * Gets or sets a boolean indicating that left and right values must be inverted
  41129. */
  41130. reverseLeftRight: boolean;
  41131. /**
  41132. * Gets or sets a boolean indicating that up and down values must be inverted
  41133. */
  41134. reverseUpDown: boolean;
  41135. /**
  41136. * Gets the offset value for the position (ie. the change of the position value)
  41137. */
  41138. deltaPosition: Vector3;
  41139. /**
  41140. * Gets a boolean indicating if the virtual joystick was pressed
  41141. */
  41142. pressed: boolean;
  41143. /**
  41144. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41145. */
  41146. static Canvas: Nullable<HTMLCanvasElement>;
  41147. private static _globalJoystickIndex;
  41148. private static vjCanvasContext;
  41149. private static vjCanvasWidth;
  41150. private static vjCanvasHeight;
  41151. private static halfWidth;
  41152. private _action;
  41153. private _axisTargetedByLeftAndRight;
  41154. private _axisTargetedByUpAndDown;
  41155. private _joystickSensibility;
  41156. private _inversedSensibility;
  41157. private _joystickPointerID;
  41158. private _joystickColor;
  41159. private _joystickPointerPos;
  41160. private _joystickPreviousPointerPos;
  41161. private _joystickPointerStartPos;
  41162. private _deltaJoystickVector;
  41163. private _leftJoystick;
  41164. private _touches;
  41165. private _onPointerDownHandlerRef;
  41166. private _onPointerMoveHandlerRef;
  41167. private _onPointerUpHandlerRef;
  41168. private _onResize;
  41169. /**
  41170. * Creates a new virtual joystick
  41171. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41172. */
  41173. constructor(leftJoystick?: boolean);
  41174. /**
  41175. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41176. * @param newJoystickSensibility defines the new sensibility
  41177. */
  41178. setJoystickSensibility(newJoystickSensibility: number): void;
  41179. private _onPointerDown;
  41180. private _onPointerMove;
  41181. private _onPointerUp;
  41182. /**
  41183. * Change the color of the virtual joystick
  41184. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41185. */
  41186. setJoystickColor(newColor: string): void;
  41187. /**
  41188. * Defines a callback to call when the joystick is touched
  41189. * @param action defines the callback
  41190. */
  41191. setActionOnTouch(action: () => any): void;
  41192. /**
  41193. * Defines which axis you'd like to control for left & right
  41194. * @param axis defines the axis to use
  41195. */
  41196. setAxisForLeftRight(axis: JoystickAxis): void;
  41197. /**
  41198. * Defines which axis you'd like to control for up & down
  41199. * @param axis defines the axis to use
  41200. */
  41201. setAxisForUpDown(axis: JoystickAxis): void;
  41202. private _drawVirtualJoystick;
  41203. /**
  41204. * Release internal HTML canvas
  41205. */
  41206. releaseCanvas(): void;
  41207. }
  41208. }
  41209. declare module BABYLON {
  41210. interface FreeCameraInputsManager {
  41211. /**
  41212. * Add virtual joystick input support to the input manager.
  41213. * @returns the current input manager
  41214. */
  41215. addVirtualJoystick(): FreeCameraInputsManager;
  41216. }
  41217. /**
  41218. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41220. */
  41221. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41222. /**
  41223. * Defines the camera the input is attached to.
  41224. */
  41225. camera: FreeCamera;
  41226. private _leftjoystick;
  41227. private _rightjoystick;
  41228. /**
  41229. * Gets the left stick of the virtual joystick.
  41230. * @returns The virtual Joystick
  41231. */
  41232. getLeftJoystick(): VirtualJoystick;
  41233. /**
  41234. * Gets the right stick of the virtual joystick.
  41235. * @returns The virtual Joystick
  41236. */
  41237. getRightJoystick(): VirtualJoystick;
  41238. /**
  41239. * Update the current camera state depending on the inputs that have been used this frame.
  41240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41241. */
  41242. checkInputs(): void;
  41243. /**
  41244. * Attach the input controls to a specific dom element to get the input from.
  41245. * @param element Defines the element the controls should be listened from
  41246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41247. */
  41248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41249. /**
  41250. * Detach the current controls from the specified dom element.
  41251. * @param element Defines the element to stop listening the inputs from
  41252. */
  41253. detachControl(element: Nullable<HTMLElement>): void;
  41254. /**
  41255. * Gets the class name of the current intput.
  41256. * @returns the class name
  41257. */
  41258. getClassName(): string;
  41259. /**
  41260. * Get the friendly name associated with the input class.
  41261. * @returns the input friendly name
  41262. */
  41263. getSimpleName(): string;
  41264. }
  41265. }
  41266. declare module BABYLON {
  41267. /**
  41268. * This represents a FPS type of camera controlled by touch.
  41269. * This is like a universal camera minus the Gamepad controls.
  41270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41271. */
  41272. export class TouchCamera extends FreeCamera {
  41273. /**
  41274. * Defines the touch sensibility for rotation.
  41275. * The higher the faster.
  41276. */
  41277. get touchAngularSensibility(): number;
  41278. set touchAngularSensibility(value: number);
  41279. /**
  41280. * Defines the touch sensibility for move.
  41281. * The higher the faster.
  41282. */
  41283. get touchMoveSensibility(): number;
  41284. set touchMoveSensibility(value: number);
  41285. /**
  41286. * Instantiates a new touch camera.
  41287. * This represents a FPS type of camera controlled by touch.
  41288. * This is like a universal camera minus the Gamepad controls.
  41289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41290. * @param name Define the name of the camera in the scene
  41291. * @param position Define the start position of the camera in the scene
  41292. * @param scene Define the scene the camera belongs to
  41293. */
  41294. constructor(name: string, position: Vector3, scene: Scene);
  41295. /**
  41296. * Gets the current object class name.
  41297. * @return the class name
  41298. */
  41299. getClassName(): string;
  41300. /** @hidden */
  41301. _setupInputs(): void;
  41302. }
  41303. }
  41304. declare module BABYLON {
  41305. /**
  41306. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41307. * being tilted forward or back and left or right.
  41308. */
  41309. export class DeviceOrientationCamera extends FreeCamera {
  41310. private _initialQuaternion;
  41311. private _quaternionCache;
  41312. private _tmpDragQuaternion;
  41313. private _disablePointerInputWhenUsingDeviceOrientation;
  41314. /**
  41315. * Creates a new device orientation camera
  41316. * @param name The name of the camera
  41317. * @param position The start position camera
  41318. * @param scene The scene the camera belongs to
  41319. */
  41320. constructor(name: string, position: Vector3, scene: Scene);
  41321. /**
  41322. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41323. */
  41324. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41325. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41326. private _dragFactor;
  41327. /**
  41328. * Enabled turning on the y axis when the orientation sensor is active
  41329. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41330. */
  41331. enableHorizontalDragging(dragFactor?: number): void;
  41332. /**
  41333. * Gets the current instance class name ("DeviceOrientationCamera").
  41334. * This helps avoiding instanceof at run time.
  41335. * @returns the class name
  41336. */
  41337. getClassName(): string;
  41338. /**
  41339. * @hidden
  41340. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41341. */
  41342. _checkInputs(): void;
  41343. /**
  41344. * Reset the camera to its default orientation on the specified axis only.
  41345. * @param axis The axis to reset
  41346. */
  41347. resetToCurrentRotation(axis?: Axis): void;
  41348. }
  41349. }
  41350. declare module BABYLON {
  41351. /**
  41352. * Defines supported buttons for XBox360 compatible gamepads
  41353. */
  41354. export enum Xbox360Button {
  41355. /** A */
  41356. A = 0,
  41357. /** B */
  41358. B = 1,
  41359. /** X */
  41360. X = 2,
  41361. /** Y */
  41362. Y = 3,
  41363. /** Left button */
  41364. LB = 4,
  41365. /** Right button */
  41366. RB = 5,
  41367. /** Back */
  41368. Back = 8,
  41369. /** Start */
  41370. Start = 9,
  41371. /** Left stick */
  41372. LeftStick = 10,
  41373. /** Right stick */
  41374. RightStick = 11
  41375. }
  41376. /** Defines values for XBox360 DPad */
  41377. export enum Xbox360Dpad {
  41378. /** Up */
  41379. Up = 12,
  41380. /** Down */
  41381. Down = 13,
  41382. /** Left */
  41383. Left = 14,
  41384. /** Right */
  41385. Right = 15
  41386. }
  41387. /**
  41388. * Defines a XBox360 gamepad
  41389. */
  41390. export class Xbox360Pad extends Gamepad {
  41391. private _leftTrigger;
  41392. private _rightTrigger;
  41393. private _onlefttriggerchanged;
  41394. private _onrighttriggerchanged;
  41395. private _onbuttondown;
  41396. private _onbuttonup;
  41397. private _ondpaddown;
  41398. private _ondpadup;
  41399. /** Observable raised when a button is pressed */
  41400. onButtonDownObservable: Observable<Xbox360Button>;
  41401. /** Observable raised when a button is released */
  41402. onButtonUpObservable: Observable<Xbox360Button>;
  41403. /** Observable raised when a pad is pressed */
  41404. onPadDownObservable: Observable<Xbox360Dpad>;
  41405. /** Observable raised when a pad is released */
  41406. onPadUpObservable: Observable<Xbox360Dpad>;
  41407. private _buttonA;
  41408. private _buttonB;
  41409. private _buttonX;
  41410. private _buttonY;
  41411. private _buttonBack;
  41412. private _buttonStart;
  41413. private _buttonLB;
  41414. private _buttonRB;
  41415. private _buttonLeftStick;
  41416. private _buttonRightStick;
  41417. private _dPadUp;
  41418. private _dPadDown;
  41419. private _dPadLeft;
  41420. private _dPadRight;
  41421. private _isXboxOnePad;
  41422. /**
  41423. * Creates a new XBox360 gamepad object
  41424. * @param id defines the id of this gamepad
  41425. * @param index defines its index
  41426. * @param gamepad defines the internal HTML gamepad object
  41427. * @param xboxOne defines if it is a XBox One gamepad
  41428. */
  41429. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41430. /**
  41431. * Defines the callback to call when left trigger is pressed
  41432. * @param callback defines the callback to use
  41433. */
  41434. onlefttriggerchanged(callback: (value: number) => void): void;
  41435. /**
  41436. * Defines the callback to call when right trigger is pressed
  41437. * @param callback defines the callback to use
  41438. */
  41439. onrighttriggerchanged(callback: (value: number) => void): void;
  41440. /**
  41441. * Gets the left trigger value
  41442. */
  41443. get leftTrigger(): number;
  41444. /**
  41445. * Sets the left trigger value
  41446. */
  41447. set leftTrigger(newValue: number);
  41448. /**
  41449. * Gets the right trigger value
  41450. */
  41451. get rightTrigger(): number;
  41452. /**
  41453. * Sets the right trigger value
  41454. */
  41455. set rightTrigger(newValue: number);
  41456. /**
  41457. * Defines the callback to call when a button is pressed
  41458. * @param callback defines the callback to use
  41459. */
  41460. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41461. /**
  41462. * Defines the callback to call when a button is released
  41463. * @param callback defines the callback to use
  41464. */
  41465. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41466. /**
  41467. * Defines the callback to call when a pad is pressed
  41468. * @param callback defines the callback to use
  41469. */
  41470. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41471. /**
  41472. * Defines the callback to call when a pad is released
  41473. * @param callback defines the callback to use
  41474. */
  41475. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41476. private _setButtonValue;
  41477. private _setDPadValue;
  41478. /**
  41479. * Gets the value of the `A` button
  41480. */
  41481. get buttonA(): number;
  41482. /**
  41483. * Sets the value of the `A` button
  41484. */
  41485. set buttonA(value: number);
  41486. /**
  41487. * Gets the value of the `B` button
  41488. */
  41489. get buttonB(): number;
  41490. /**
  41491. * Sets the value of the `B` button
  41492. */
  41493. set buttonB(value: number);
  41494. /**
  41495. * Gets the value of the `X` button
  41496. */
  41497. get buttonX(): number;
  41498. /**
  41499. * Sets the value of the `X` button
  41500. */
  41501. set buttonX(value: number);
  41502. /**
  41503. * Gets the value of the `Y` button
  41504. */
  41505. get buttonY(): number;
  41506. /**
  41507. * Sets the value of the `Y` button
  41508. */
  41509. set buttonY(value: number);
  41510. /**
  41511. * Gets the value of the `Start` button
  41512. */
  41513. get buttonStart(): number;
  41514. /**
  41515. * Sets the value of the `Start` button
  41516. */
  41517. set buttonStart(value: number);
  41518. /**
  41519. * Gets the value of the `Back` button
  41520. */
  41521. get buttonBack(): number;
  41522. /**
  41523. * Sets the value of the `Back` button
  41524. */
  41525. set buttonBack(value: number);
  41526. /**
  41527. * Gets the value of the `Left` button
  41528. */
  41529. get buttonLB(): number;
  41530. /**
  41531. * Sets the value of the `Left` button
  41532. */
  41533. set buttonLB(value: number);
  41534. /**
  41535. * Gets the value of the `Right` button
  41536. */
  41537. get buttonRB(): number;
  41538. /**
  41539. * Sets the value of the `Right` button
  41540. */
  41541. set buttonRB(value: number);
  41542. /**
  41543. * Gets the value of the Left joystick
  41544. */
  41545. get buttonLeftStick(): number;
  41546. /**
  41547. * Sets the value of the Left joystick
  41548. */
  41549. set buttonLeftStick(value: number);
  41550. /**
  41551. * Gets the value of the Right joystick
  41552. */
  41553. get buttonRightStick(): number;
  41554. /**
  41555. * Sets the value of the Right joystick
  41556. */
  41557. set buttonRightStick(value: number);
  41558. /**
  41559. * Gets the value of D-pad up
  41560. */
  41561. get dPadUp(): number;
  41562. /**
  41563. * Sets the value of D-pad up
  41564. */
  41565. set dPadUp(value: number);
  41566. /**
  41567. * Gets the value of D-pad down
  41568. */
  41569. get dPadDown(): number;
  41570. /**
  41571. * Sets the value of D-pad down
  41572. */
  41573. set dPadDown(value: number);
  41574. /**
  41575. * Gets the value of D-pad left
  41576. */
  41577. get dPadLeft(): number;
  41578. /**
  41579. * Sets the value of D-pad left
  41580. */
  41581. set dPadLeft(value: number);
  41582. /**
  41583. * Gets the value of D-pad right
  41584. */
  41585. get dPadRight(): number;
  41586. /**
  41587. * Sets the value of D-pad right
  41588. */
  41589. set dPadRight(value: number);
  41590. /**
  41591. * Force the gamepad to synchronize with device values
  41592. */
  41593. update(): void;
  41594. /**
  41595. * Disposes the gamepad
  41596. */
  41597. dispose(): void;
  41598. }
  41599. }
  41600. declare module BABYLON {
  41601. /**
  41602. * Defines supported buttons for DualShock compatible gamepads
  41603. */
  41604. export enum DualShockButton {
  41605. /** Cross */
  41606. Cross = 0,
  41607. /** Circle */
  41608. Circle = 1,
  41609. /** Square */
  41610. Square = 2,
  41611. /** Triangle */
  41612. Triangle = 3,
  41613. /** L1 */
  41614. L1 = 4,
  41615. /** R1 */
  41616. R1 = 5,
  41617. /** Share */
  41618. Share = 8,
  41619. /** Options */
  41620. Options = 9,
  41621. /** Left stick */
  41622. LeftStick = 10,
  41623. /** Right stick */
  41624. RightStick = 11
  41625. }
  41626. /** Defines values for DualShock DPad */
  41627. export enum DualShockDpad {
  41628. /** Up */
  41629. Up = 12,
  41630. /** Down */
  41631. Down = 13,
  41632. /** Left */
  41633. Left = 14,
  41634. /** Right */
  41635. Right = 15
  41636. }
  41637. /**
  41638. * Defines a DualShock gamepad
  41639. */
  41640. export class DualShockPad extends Gamepad {
  41641. private _leftTrigger;
  41642. private _rightTrigger;
  41643. private _onlefttriggerchanged;
  41644. private _onrighttriggerchanged;
  41645. private _onbuttondown;
  41646. private _onbuttonup;
  41647. private _ondpaddown;
  41648. private _ondpadup;
  41649. /** Observable raised when a button is pressed */
  41650. onButtonDownObservable: Observable<DualShockButton>;
  41651. /** Observable raised when a button is released */
  41652. onButtonUpObservable: Observable<DualShockButton>;
  41653. /** Observable raised when a pad is pressed */
  41654. onPadDownObservable: Observable<DualShockDpad>;
  41655. /** Observable raised when a pad is released */
  41656. onPadUpObservable: Observable<DualShockDpad>;
  41657. private _buttonCross;
  41658. private _buttonCircle;
  41659. private _buttonSquare;
  41660. private _buttonTriangle;
  41661. private _buttonShare;
  41662. private _buttonOptions;
  41663. private _buttonL1;
  41664. private _buttonR1;
  41665. private _buttonLeftStick;
  41666. private _buttonRightStick;
  41667. private _dPadUp;
  41668. private _dPadDown;
  41669. private _dPadLeft;
  41670. private _dPadRight;
  41671. /**
  41672. * Creates a new DualShock gamepad object
  41673. * @param id defines the id of this gamepad
  41674. * @param index defines its index
  41675. * @param gamepad defines the internal HTML gamepad object
  41676. */
  41677. constructor(id: string, index: number, gamepad: any);
  41678. /**
  41679. * Defines the callback to call when left trigger is pressed
  41680. * @param callback defines the callback to use
  41681. */
  41682. onlefttriggerchanged(callback: (value: number) => void): void;
  41683. /**
  41684. * Defines the callback to call when right trigger is pressed
  41685. * @param callback defines the callback to use
  41686. */
  41687. onrighttriggerchanged(callback: (value: number) => void): void;
  41688. /**
  41689. * Gets the left trigger value
  41690. */
  41691. get leftTrigger(): number;
  41692. /**
  41693. * Sets the left trigger value
  41694. */
  41695. set leftTrigger(newValue: number);
  41696. /**
  41697. * Gets the right trigger value
  41698. */
  41699. get rightTrigger(): number;
  41700. /**
  41701. * Sets the right trigger value
  41702. */
  41703. set rightTrigger(newValue: number);
  41704. /**
  41705. * Defines the callback to call when a button is pressed
  41706. * @param callback defines the callback to use
  41707. */
  41708. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41709. /**
  41710. * Defines the callback to call when a button is released
  41711. * @param callback defines the callback to use
  41712. */
  41713. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41714. /**
  41715. * Defines the callback to call when a pad is pressed
  41716. * @param callback defines the callback to use
  41717. */
  41718. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41719. /**
  41720. * Defines the callback to call when a pad is released
  41721. * @param callback defines the callback to use
  41722. */
  41723. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41724. private _setButtonValue;
  41725. private _setDPadValue;
  41726. /**
  41727. * Gets the value of the `Cross` button
  41728. */
  41729. get buttonCross(): number;
  41730. /**
  41731. * Sets the value of the `Cross` button
  41732. */
  41733. set buttonCross(value: number);
  41734. /**
  41735. * Gets the value of the `Circle` button
  41736. */
  41737. get buttonCircle(): number;
  41738. /**
  41739. * Sets the value of the `Circle` button
  41740. */
  41741. set buttonCircle(value: number);
  41742. /**
  41743. * Gets the value of the `Square` button
  41744. */
  41745. get buttonSquare(): number;
  41746. /**
  41747. * Sets the value of the `Square` button
  41748. */
  41749. set buttonSquare(value: number);
  41750. /**
  41751. * Gets the value of the `Triangle` button
  41752. */
  41753. get buttonTriangle(): number;
  41754. /**
  41755. * Sets the value of the `Triangle` button
  41756. */
  41757. set buttonTriangle(value: number);
  41758. /**
  41759. * Gets the value of the `Options` button
  41760. */
  41761. get buttonOptions(): number;
  41762. /**
  41763. * Sets the value of the `Options` button
  41764. */
  41765. set buttonOptions(value: number);
  41766. /**
  41767. * Gets the value of the `Share` button
  41768. */
  41769. get buttonShare(): number;
  41770. /**
  41771. * Sets the value of the `Share` button
  41772. */
  41773. set buttonShare(value: number);
  41774. /**
  41775. * Gets the value of the `L1` button
  41776. */
  41777. get buttonL1(): number;
  41778. /**
  41779. * Sets the value of the `L1` button
  41780. */
  41781. set buttonL1(value: number);
  41782. /**
  41783. * Gets the value of the `R1` button
  41784. */
  41785. get buttonR1(): number;
  41786. /**
  41787. * Sets the value of the `R1` button
  41788. */
  41789. set buttonR1(value: number);
  41790. /**
  41791. * Gets the value of the Left joystick
  41792. */
  41793. get buttonLeftStick(): number;
  41794. /**
  41795. * Sets the value of the Left joystick
  41796. */
  41797. set buttonLeftStick(value: number);
  41798. /**
  41799. * Gets the value of the Right joystick
  41800. */
  41801. get buttonRightStick(): number;
  41802. /**
  41803. * Sets the value of the Right joystick
  41804. */
  41805. set buttonRightStick(value: number);
  41806. /**
  41807. * Gets the value of D-pad up
  41808. */
  41809. get dPadUp(): number;
  41810. /**
  41811. * Sets the value of D-pad up
  41812. */
  41813. set dPadUp(value: number);
  41814. /**
  41815. * Gets the value of D-pad down
  41816. */
  41817. get dPadDown(): number;
  41818. /**
  41819. * Sets the value of D-pad down
  41820. */
  41821. set dPadDown(value: number);
  41822. /**
  41823. * Gets the value of D-pad left
  41824. */
  41825. get dPadLeft(): number;
  41826. /**
  41827. * Sets the value of D-pad left
  41828. */
  41829. set dPadLeft(value: number);
  41830. /**
  41831. * Gets the value of D-pad right
  41832. */
  41833. get dPadRight(): number;
  41834. /**
  41835. * Sets the value of D-pad right
  41836. */
  41837. set dPadRight(value: number);
  41838. /**
  41839. * Force the gamepad to synchronize with device values
  41840. */
  41841. update(): void;
  41842. /**
  41843. * Disposes the gamepad
  41844. */
  41845. dispose(): void;
  41846. }
  41847. }
  41848. declare module BABYLON {
  41849. /**
  41850. * Manager for handling gamepads
  41851. */
  41852. export class GamepadManager {
  41853. private _scene?;
  41854. private _babylonGamepads;
  41855. private _oneGamepadConnected;
  41856. /** @hidden */
  41857. _isMonitoring: boolean;
  41858. private _gamepadEventSupported;
  41859. private _gamepadSupport?;
  41860. /**
  41861. * observable to be triggered when the gamepad controller has been connected
  41862. */
  41863. onGamepadConnectedObservable: Observable<Gamepad>;
  41864. /**
  41865. * observable to be triggered when the gamepad controller has been disconnected
  41866. */
  41867. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41868. private _onGamepadConnectedEvent;
  41869. private _onGamepadDisconnectedEvent;
  41870. /**
  41871. * Initializes the gamepad manager
  41872. * @param _scene BabylonJS scene
  41873. */
  41874. constructor(_scene?: Scene | undefined);
  41875. /**
  41876. * The gamepads in the game pad manager
  41877. */
  41878. get gamepads(): Gamepad[];
  41879. /**
  41880. * Get the gamepad controllers based on type
  41881. * @param type The type of gamepad controller
  41882. * @returns Nullable gamepad
  41883. */
  41884. getGamepadByType(type?: number): Nullable<Gamepad>;
  41885. /**
  41886. * Disposes the gamepad manager
  41887. */
  41888. dispose(): void;
  41889. private _addNewGamepad;
  41890. private _startMonitoringGamepads;
  41891. private _stopMonitoringGamepads;
  41892. /** @hidden */
  41893. _checkGamepadsStatus(): void;
  41894. private _updateGamepadObjects;
  41895. }
  41896. }
  41897. declare module BABYLON {
  41898. interface Scene {
  41899. /** @hidden */
  41900. _gamepadManager: Nullable<GamepadManager>;
  41901. /**
  41902. * Gets the gamepad manager associated with the scene
  41903. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41904. */
  41905. gamepadManager: GamepadManager;
  41906. }
  41907. /**
  41908. * Interface representing a free camera inputs manager
  41909. */
  41910. interface FreeCameraInputsManager {
  41911. /**
  41912. * Adds gamepad input support to the FreeCameraInputsManager.
  41913. * @returns the FreeCameraInputsManager
  41914. */
  41915. addGamepad(): FreeCameraInputsManager;
  41916. }
  41917. /**
  41918. * Interface representing an arc rotate camera inputs manager
  41919. */
  41920. interface ArcRotateCameraInputsManager {
  41921. /**
  41922. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41923. * @returns the camera inputs manager
  41924. */
  41925. addGamepad(): ArcRotateCameraInputsManager;
  41926. }
  41927. /**
  41928. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41929. */
  41930. export class GamepadSystemSceneComponent implements ISceneComponent {
  41931. /**
  41932. * The component name helpfull to identify the component in the list of scene components.
  41933. */
  41934. readonly name: string;
  41935. /**
  41936. * The scene the component belongs to.
  41937. */
  41938. scene: Scene;
  41939. /**
  41940. * Creates a new instance of the component for the given scene
  41941. * @param scene Defines the scene to register the component in
  41942. */
  41943. constructor(scene: Scene);
  41944. /**
  41945. * Registers the component in a given scene
  41946. */
  41947. register(): void;
  41948. /**
  41949. * Rebuilds the elements related to this component in case of
  41950. * context lost for instance.
  41951. */
  41952. rebuild(): void;
  41953. /**
  41954. * Disposes the component and the associated ressources
  41955. */
  41956. dispose(): void;
  41957. private _beforeCameraUpdate;
  41958. }
  41959. }
  41960. declare module BABYLON {
  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. */
  41966. export class UniversalCamera extends TouchCamera {
  41967. /**
  41968. * Defines the gamepad rotation sensiblity.
  41969. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41970. */
  41971. get gamepadAngularSensibility(): number;
  41972. set gamepadAngularSensibility(value: number);
  41973. /**
  41974. * Defines the gamepad move sensiblity.
  41975. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41976. */
  41977. get gamepadMoveSensibility(): number;
  41978. set gamepadMoveSensibility(value: number);
  41979. /**
  41980. * 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,
  41981. * which still works and will still be found in many Playgrounds.
  41982. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41983. * @param name Define the name of the camera in the scene
  41984. * @param position Define the start position of the camera in the scene
  41985. * @param scene Define the scene the camera belongs to
  41986. */
  41987. constructor(name: string, position: Vector3, scene: Scene);
  41988. /**
  41989. * Gets the current object class name.
  41990. * @return the class name
  41991. */
  41992. getClassName(): string;
  41993. }
  41994. }
  41995. declare module BABYLON {
  41996. /**
  41997. * This represents a FPS type of camera. This is only here for back compat purpose.
  41998. * Please use the UniversalCamera instead as both are identical.
  41999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42000. */
  42001. export class GamepadCamera extends UniversalCamera {
  42002. /**
  42003. * Instantiates a new Gamepad Camera
  42004. * This represents a FPS type of camera. This is only here for back compat purpose.
  42005. * Please use the UniversalCamera instead as both are identical.
  42006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42007. * @param name Define the name of the camera in the scene
  42008. * @param position Define the start position of the camera in the scene
  42009. * @param scene Define the scene the camera belongs to
  42010. */
  42011. constructor(name: string, position: Vector3, scene: Scene);
  42012. /**
  42013. * Gets the current object class name.
  42014. * @return the class name
  42015. */
  42016. getClassName(): string;
  42017. }
  42018. }
  42019. declare module BABYLON {
  42020. /** @hidden */
  42021. export var passPixelShader: {
  42022. name: string;
  42023. shader: string;
  42024. };
  42025. }
  42026. declare module BABYLON {
  42027. /** @hidden */
  42028. export var passCubePixelShader: {
  42029. name: string;
  42030. shader: string;
  42031. };
  42032. }
  42033. declare module BABYLON {
  42034. /**
  42035. * PassPostProcess which produces an output the same as it's input
  42036. */
  42037. export class PassPostProcess extends PostProcess {
  42038. /**
  42039. * Creates the PassPostProcess
  42040. * @param name The name of the effect.
  42041. * @param options The required width/height ratio to downsize to before computing the render pass.
  42042. * @param camera The camera to apply the render pass to.
  42043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42044. * @param engine The engine which the post process will be applied. (default: current engine)
  42045. * @param reusable If the post process can be reused on the same frame. (default: false)
  42046. * @param textureType The type of texture to be used when performing the post processing.
  42047. * @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)
  42048. */
  42049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42050. }
  42051. /**
  42052. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42053. */
  42054. export class PassCubePostProcess extends PostProcess {
  42055. private _face;
  42056. /**
  42057. * Gets or sets the cube face to display.
  42058. * * 0 is +X
  42059. * * 1 is -X
  42060. * * 2 is +Y
  42061. * * 3 is -Y
  42062. * * 4 is +Z
  42063. * * 5 is -Z
  42064. */
  42065. get face(): number;
  42066. set face(value: number);
  42067. /**
  42068. * Creates the PassCubePostProcess
  42069. * @param name The name of the effect.
  42070. * @param options The required width/height ratio to downsize to before computing the render pass.
  42071. * @param camera The camera to apply the render pass to.
  42072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42073. * @param engine The engine which the post process will be applied. (default: current engine)
  42074. * @param reusable If the post process can be reused on the same frame. (default: false)
  42075. * @param textureType The type of texture to be used when performing the post processing.
  42076. * @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)
  42077. */
  42078. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42079. }
  42080. }
  42081. declare module BABYLON {
  42082. /** @hidden */
  42083. export var anaglyphPixelShader: {
  42084. name: string;
  42085. shader: string;
  42086. };
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * Postprocess used to generate anaglyphic rendering
  42091. */
  42092. export class AnaglyphPostProcess extends PostProcess {
  42093. private _passedProcess;
  42094. /**
  42095. * Creates a new AnaglyphPostProcess
  42096. * @param name defines postprocess name
  42097. * @param options defines creation options or target ratio scale
  42098. * @param rigCameras defines cameras using this postprocess
  42099. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42100. * @param engine defines hosting engine
  42101. * @param reusable defines if the postprocess will be reused multiple times per frame
  42102. */
  42103. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42104. }
  42105. }
  42106. declare module BABYLON {
  42107. /**
  42108. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42109. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42110. */
  42111. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42112. /**
  42113. * Creates a new AnaglyphArcRotateCamera
  42114. * @param name defines camera name
  42115. * @param alpha defines alpha angle (in radians)
  42116. * @param beta defines beta angle (in radians)
  42117. * @param radius defines radius
  42118. * @param target defines camera target
  42119. * @param interaxialDistance defines distance between each color axis
  42120. * @param scene defines the hosting scene
  42121. */
  42122. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42123. /**
  42124. * Gets camera class name
  42125. * @returns AnaglyphArcRotateCamera
  42126. */
  42127. getClassName(): string;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42133. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42134. */
  42135. export class AnaglyphFreeCamera extends FreeCamera {
  42136. /**
  42137. * Creates a new AnaglyphFreeCamera
  42138. * @param name defines camera name
  42139. * @param position defines initial position
  42140. * @param interaxialDistance defines distance between each color axis
  42141. * @param scene defines the hosting scene
  42142. */
  42143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42144. /**
  42145. * Gets camera class name
  42146. * @returns AnaglyphFreeCamera
  42147. */
  42148. getClassName(): string;
  42149. }
  42150. }
  42151. declare module BABYLON {
  42152. /**
  42153. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42154. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42155. */
  42156. export class AnaglyphGamepadCamera extends GamepadCamera {
  42157. /**
  42158. * Creates a new AnaglyphGamepadCamera
  42159. * @param name defines camera name
  42160. * @param position defines initial position
  42161. * @param interaxialDistance defines distance between each color axis
  42162. * @param scene defines the hosting scene
  42163. */
  42164. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42165. /**
  42166. * Gets camera class name
  42167. * @returns AnaglyphGamepadCamera
  42168. */
  42169. getClassName(): string;
  42170. }
  42171. }
  42172. declare module BABYLON {
  42173. /**
  42174. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42176. */
  42177. export class AnaglyphUniversalCamera extends UniversalCamera {
  42178. /**
  42179. * Creates a new AnaglyphUniversalCamera
  42180. * @param name defines camera name
  42181. * @param position defines initial position
  42182. * @param interaxialDistance defines distance between each color axis
  42183. * @param scene defines the hosting scene
  42184. */
  42185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42186. /**
  42187. * Gets camera class name
  42188. * @returns AnaglyphUniversalCamera
  42189. */
  42190. getClassName(): string;
  42191. }
  42192. }
  42193. declare module BABYLON {
  42194. /** @hidden */
  42195. export var stereoscopicInterlacePixelShader: {
  42196. name: string;
  42197. shader: string;
  42198. };
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42203. */
  42204. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42205. private _stepSize;
  42206. private _passedProcess;
  42207. /**
  42208. * Initializes a StereoscopicInterlacePostProcessI
  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 vertical
  42212. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42214. * @param engine The engine which the post process will be applied. (default: current engine)
  42215. * @param reusable If the post process can be reused on the same frame. (default: false)
  42216. */
  42217. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42218. }
  42219. /**
  42220. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42221. */
  42222. export class StereoscopicInterlacePostProcess extends PostProcess {
  42223. private _stepSize;
  42224. private _passedProcess;
  42225. /**
  42226. * Initializes a StereoscopicInterlacePostProcess
  42227. * @param name The name of the effect.
  42228. * @param rigCameras The rig cameras to be appled to the post process
  42229. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42231. * @param engine The engine which the post process will be applied. (default: current engine)
  42232. * @param reusable If the post process can be reused on the same frame. (default: false)
  42233. */
  42234. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42235. }
  42236. }
  42237. declare module BABYLON {
  42238. /**
  42239. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42240. * @see http://doc.babylonjs.com/features/cameras
  42241. */
  42242. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42243. /**
  42244. * Creates a new StereoscopicArcRotateCamera
  42245. * @param name defines camera name
  42246. * @param alpha defines alpha angle (in radians)
  42247. * @param beta defines beta angle (in radians)
  42248. * @param radius defines radius
  42249. * @param target defines camera target
  42250. * @param interaxialDistance defines distance between each color axis
  42251. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42252. * @param scene defines the hosting scene
  42253. */
  42254. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42255. /**
  42256. * Gets camera class name
  42257. * @returns StereoscopicArcRotateCamera
  42258. */
  42259. getClassName(): string;
  42260. }
  42261. }
  42262. declare module BABYLON {
  42263. /**
  42264. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42265. * @see http://doc.babylonjs.com/features/cameras
  42266. */
  42267. export class StereoscopicFreeCamera extends FreeCamera {
  42268. /**
  42269. * Creates a new StereoscopicFreeCamera
  42270. * @param name defines camera name
  42271. * @param position defines initial position
  42272. * @param interaxialDistance defines distance between each color axis
  42273. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42274. * @param scene defines the hosting scene
  42275. */
  42276. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42277. /**
  42278. * Gets camera class name
  42279. * @returns StereoscopicFreeCamera
  42280. */
  42281. getClassName(): string;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42287. * @see http://doc.babylonjs.com/features/cameras
  42288. */
  42289. export class StereoscopicGamepadCamera extends GamepadCamera {
  42290. /**
  42291. * Creates a new StereoscopicGamepadCamera
  42292. * @param name defines camera name
  42293. * @param position defines initial position
  42294. * @param interaxialDistance defines distance between each color axis
  42295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42296. * @param scene defines the hosting scene
  42297. */
  42298. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42299. /**
  42300. * Gets camera class name
  42301. * @returns StereoscopicGamepadCamera
  42302. */
  42303. getClassName(): string;
  42304. }
  42305. }
  42306. declare module BABYLON {
  42307. /**
  42308. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42309. * @see http://doc.babylonjs.com/features/cameras
  42310. */
  42311. export class StereoscopicUniversalCamera extends UniversalCamera {
  42312. /**
  42313. * Creates a new StereoscopicUniversalCamera
  42314. * @param name defines camera name
  42315. * @param position defines initial position
  42316. * @param interaxialDistance defines distance between each color axis
  42317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42318. * @param scene defines the hosting scene
  42319. */
  42320. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42321. /**
  42322. * Gets camera class name
  42323. * @returns StereoscopicUniversalCamera
  42324. */
  42325. getClassName(): string;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42331. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42332. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42333. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42334. */
  42335. export class VirtualJoysticksCamera extends FreeCamera {
  42336. /**
  42337. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42338. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42339. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42340. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42341. * @param name Define the name of the camera in the scene
  42342. * @param position Define the start position of the camera in the scene
  42343. * @param scene Define the scene the camera belongs to
  42344. */
  42345. constructor(name: string, position: Vector3, scene: Scene);
  42346. /**
  42347. * Gets the current object class name.
  42348. * @return the class name
  42349. */
  42350. getClassName(): string;
  42351. }
  42352. }
  42353. declare module BABYLON {
  42354. /**
  42355. * This represents all the required metrics to create a VR camera.
  42356. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42357. */
  42358. export class VRCameraMetrics {
  42359. /**
  42360. * Define the horizontal resolution off the screen.
  42361. */
  42362. hResolution: number;
  42363. /**
  42364. * Define the vertical resolution off the screen.
  42365. */
  42366. vResolution: number;
  42367. /**
  42368. * Define the horizontal screen size.
  42369. */
  42370. hScreenSize: number;
  42371. /**
  42372. * Define the vertical screen size.
  42373. */
  42374. vScreenSize: number;
  42375. /**
  42376. * Define the vertical screen center position.
  42377. */
  42378. vScreenCenter: number;
  42379. /**
  42380. * Define the distance of the eyes to the screen.
  42381. */
  42382. eyeToScreenDistance: number;
  42383. /**
  42384. * Define the distance between both lenses
  42385. */
  42386. lensSeparationDistance: number;
  42387. /**
  42388. * Define the distance between both viewer's eyes.
  42389. */
  42390. interpupillaryDistance: number;
  42391. /**
  42392. * Define the distortion factor of the VR postprocess.
  42393. * Please, touch with care.
  42394. */
  42395. distortionK: number[];
  42396. /**
  42397. * Define the chromatic aberration correction factors for the VR post process.
  42398. */
  42399. chromaAbCorrection: number[];
  42400. /**
  42401. * Define the scale factor of the post process.
  42402. * The smaller the better but the slower.
  42403. */
  42404. postProcessScaleFactor: number;
  42405. /**
  42406. * Define an offset for the lens center.
  42407. */
  42408. lensCenterOffset: number;
  42409. /**
  42410. * Define if the current vr camera should compensate the distortion of the lense or not.
  42411. */
  42412. compensateDistortion: boolean;
  42413. /**
  42414. * Defines if multiview should be enabled when rendering (Default: false)
  42415. */
  42416. multiviewEnabled: boolean;
  42417. /**
  42418. * Gets the rendering aspect ratio based on the provided resolutions.
  42419. */
  42420. get aspectRatio(): number;
  42421. /**
  42422. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42423. */
  42424. get aspectRatioFov(): number;
  42425. /**
  42426. * @hidden
  42427. */
  42428. get leftHMatrix(): Matrix;
  42429. /**
  42430. * @hidden
  42431. */
  42432. get rightHMatrix(): Matrix;
  42433. /**
  42434. * @hidden
  42435. */
  42436. get leftPreViewMatrix(): Matrix;
  42437. /**
  42438. * @hidden
  42439. */
  42440. get rightPreViewMatrix(): Matrix;
  42441. /**
  42442. * Get the default VRMetrics based on the most generic setup.
  42443. * @returns the default vr metrics
  42444. */
  42445. static GetDefault(): VRCameraMetrics;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /** @hidden */
  42450. export var vrDistortionCorrectionPixelShader: {
  42451. name: string;
  42452. shader: string;
  42453. };
  42454. }
  42455. declare module BABYLON {
  42456. /**
  42457. * VRDistortionCorrectionPostProcess used for mobile VR
  42458. */
  42459. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42460. private _isRightEye;
  42461. private _distortionFactors;
  42462. private _postProcessScaleFactor;
  42463. private _lensCenterOffset;
  42464. private _scaleIn;
  42465. private _scaleFactor;
  42466. private _lensCenter;
  42467. /**
  42468. * Initializes the VRDistortionCorrectionPostProcess
  42469. * @param name The name of the effect.
  42470. * @param camera The camera to apply the render pass to.
  42471. * @param isRightEye If this is for the right eye distortion
  42472. * @param vrMetrics All the required metrics for the VR camera
  42473. */
  42474. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42475. }
  42476. }
  42477. declare module BABYLON {
  42478. /**
  42479. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42480. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42481. */
  42482. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42483. /**
  42484. * Creates a new VRDeviceOrientationArcRotateCamera
  42485. * @param name defines camera name
  42486. * @param alpha defines the camera rotation along the logitudinal axis
  42487. * @param beta defines the camera rotation along the latitudinal axis
  42488. * @param radius defines the camera distance from its target
  42489. * @param target defines the camera target
  42490. * @param scene defines the scene the camera belongs to
  42491. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42492. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42493. */
  42494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42495. /**
  42496. * Gets camera class name
  42497. * @returns VRDeviceOrientationArcRotateCamera
  42498. */
  42499. getClassName(): string;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * Camera used to simulate VR rendering (based on FreeCamera)
  42505. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42506. */
  42507. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42508. /**
  42509. * Creates a new VRDeviceOrientationFreeCamera
  42510. * @param name defines camera name
  42511. * @param position defines the start position of the camera
  42512. * @param scene defines the scene the camera belongs to
  42513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42515. */
  42516. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42517. /**
  42518. * Gets camera class name
  42519. * @returns VRDeviceOrientationFreeCamera
  42520. */
  42521. getClassName(): string;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42527. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42528. */
  42529. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42530. /**
  42531. * Creates a new VRDeviceOrientationGamepadCamera
  42532. * @param name defines camera name
  42533. * @param position defines the start position of the camera
  42534. * @param scene defines the scene the camera belongs to
  42535. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42536. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42537. */
  42538. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42539. /**
  42540. * Gets camera class name
  42541. * @returns VRDeviceOrientationGamepadCamera
  42542. */
  42543. getClassName(): string;
  42544. }
  42545. }
  42546. declare module BABYLON {
  42547. /** @hidden */
  42548. export var imageProcessingPixelShader: {
  42549. name: string;
  42550. shader: string;
  42551. };
  42552. }
  42553. declare module BABYLON {
  42554. /**
  42555. * ImageProcessingPostProcess
  42556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42557. */
  42558. export class ImageProcessingPostProcess extends PostProcess {
  42559. /**
  42560. * Default configuration related to image processing available in the PBR Material.
  42561. */
  42562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42563. /**
  42564. * Gets the image processing configuration used either in this material.
  42565. */
  42566. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42567. /**
  42568. * Sets the Default image processing configuration used either in the this material.
  42569. *
  42570. * If sets to null, the scene one is in use.
  42571. */
  42572. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42573. /**
  42574. * Keep track of the image processing observer to allow dispose and replace.
  42575. */
  42576. private _imageProcessingObserver;
  42577. /**
  42578. * Attaches a new image processing configuration to the PBR Material.
  42579. * @param configuration
  42580. */
  42581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42582. /**
  42583. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42584. */
  42585. get colorCurves(): Nullable<ColorCurves>;
  42586. /**
  42587. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42588. */
  42589. set colorCurves(value: Nullable<ColorCurves>);
  42590. /**
  42591. * Gets wether the color curves effect is enabled.
  42592. */
  42593. get colorCurvesEnabled(): boolean;
  42594. /**
  42595. * Sets wether the color curves effect is enabled.
  42596. */
  42597. set colorCurvesEnabled(value: boolean);
  42598. /**
  42599. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42600. */
  42601. get colorGradingTexture(): Nullable<BaseTexture>;
  42602. /**
  42603. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42604. */
  42605. set colorGradingTexture(value: Nullable<BaseTexture>);
  42606. /**
  42607. * Gets wether the color grading effect is enabled.
  42608. */
  42609. get colorGradingEnabled(): boolean;
  42610. /**
  42611. * Gets wether the color grading effect is enabled.
  42612. */
  42613. set colorGradingEnabled(value: boolean);
  42614. /**
  42615. * Gets exposure used in the effect.
  42616. */
  42617. get exposure(): number;
  42618. /**
  42619. * Sets exposure used in the effect.
  42620. */
  42621. set exposure(value: number);
  42622. /**
  42623. * Gets wether tonemapping is enabled or not.
  42624. */
  42625. get toneMappingEnabled(): boolean;
  42626. /**
  42627. * Sets wether tonemapping is enabled or not
  42628. */
  42629. set toneMappingEnabled(value: boolean);
  42630. /**
  42631. * Gets the type of tone mapping effect.
  42632. */
  42633. get toneMappingType(): number;
  42634. /**
  42635. * Sets the type of tone mapping effect.
  42636. */
  42637. set toneMappingType(value: number);
  42638. /**
  42639. * Gets contrast used in the effect.
  42640. */
  42641. get contrast(): number;
  42642. /**
  42643. * Sets contrast used in the effect.
  42644. */
  42645. set contrast(value: number);
  42646. /**
  42647. * Gets Vignette stretch size.
  42648. */
  42649. get vignetteStretch(): number;
  42650. /**
  42651. * Sets Vignette stretch size.
  42652. */
  42653. set vignetteStretch(value: number);
  42654. /**
  42655. * Gets Vignette centre X Offset.
  42656. */
  42657. get vignetteCentreX(): number;
  42658. /**
  42659. * Sets Vignette centre X Offset.
  42660. */
  42661. set vignetteCentreX(value: number);
  42662. /**
  42663. * Gets Vignette centre Y Offset.
  42664. */
  42665. get vignetteCentreY(): number;
  42666. /**
  42667. * Sets Vignette centre Y Offset.
  42668. */
  42669. set vignetteCentreY(value: number);
  42670. /**
  42671. * Gets Vignette weight or intensity of the vignette effect.
  42672. */
  42673. get vignetteWeight(): number;
  42674. /**
  42675. * Sets Vignette weight or intensity of the vignette effect.
  42676. */
  42677. set vignetteWeight(value: number);
  42678. /**
  42679. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42680. * if vignetteEnabled is set to true.
  42681. */
  42682. get vignetteColor(): Color4;
  42683. /**
  42684. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42685. * if vignetteEnabled is set to true.
  42686. */
  42687. set vignetteColor(value: Color4);
  42688. /**
  42689. * Gets Camera field of view used by the Vignette effect.
  42690. */
  42691. get vignetteCameraFov(): number;
  42692. /**
  42693. * Sets Camera field of view used by the Vignette effect.
  42694. */
  42695. set vignetteCameraFov(value: number);
  42696. /**
  42697. * Gets the vignette blend mode allowing different kind of effect.
  42698. */
  42699. get vignetteBlendMode(): number;
  42700. /**
  42701. * Sets the vignette blend mode allowing different kind of effect.
  42702. */
  42703. set vignetteBlendMode(value: number);
  42704. /**
  42705. * Gets wether the vignette effect is enabled.
  42706. */
  42707. get vignetteEnabled(): boolean;
  42708. /**
  42709. * Sets wether the vignette effect is enabled.
  42710. */
  42711. set vignetteEnabled(value: boolean);
  42712. private _fromLinearSpace;
  42713. /**
  42714. * Gets wether the input of the processing is in Gamma or Linear Space.
  42715. */
  42716. get fromLinearSpace(): boolean;
  42717. /**
  42718. * Sets wether the input of the processing is in Gamma or Linear Space.
  42719. */
  42720. set fromLinearSpace(value: boolean);
  42721. /**
  42722. * Defines cache preventing GC.
  42723. */
  42724. private _defines;
  42725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42726. /**
  42727. * "ImageProcessingPostProcess"
  42728. * @returns "ImageProcessingPostProcess"
  42729. */
  42730. getClassName(): string;
  42731. protected _updateParameters(): void;
  42732. dispose(camera?: Camera): void;
  42733. }
  42734. }
  42735. declare module BABYLON {
  42736. /**
  42737. * Class containing static functions to help procedurally build meshes
  42738. */
  42739. export class GroundBuilder {
  42740. /**
  42741. * Creates a ground mesh
  42742. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42743. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42745. * @param name defines the name of the mesh
  42746. * @param options defines the options used to create the mesh
  42747. * @param scene defines the hosting scene
  42748. * @returns the ground mesh
  42749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42750. */
  42751. static CreateGround(name: string, options: {
  42752. width?: number;
  42753. height?: number;
  42754. subdivisions?: number;
  42755. subdivisionsX?: number;
  42756. subdivisionsY?: number;
  42757. updatable?: boolean;
  42758. }, scene: any): Mesh;
  42759. /**
  42760. * Creates a tiled ground mesh
  42761. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42762. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42763. * * 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
  42764. * * 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
  42765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42766. * @param name defines the name of the mesh
  42767. * @param options defines the options used to create the mesh
  42768. * @param scene defines the hosting scene
  42769. * @returns the tiled ground mesh
  42770. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42771. */
  42772. static CreateTiledGround(name: string, options: {
  42773. xmin: number;
  42774. zmin: number;
  42775. xmax: number;
  42776. zmax: number;
  42777. subdivisions?: {
  42778. w: number;
  42779. h: number;
  42780. };
  42781. precision?: {
  42782. w: number;
  42783. h: number;
  42784. };
  42785. updatable?: boolean;
  42786. }, scene?: Nullable<Scene>): Mesh;
  42787. /**
  42788. * Creates a ground mesh from a height map
  42789. * * The parameter `url` sets the URL of the height map image resource.
  42790. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42791. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42792. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42793. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42794. * * 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.
  42795. * * 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).
  42796. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42798. * @param name defines the name of the mesh
  42799. * @param url defines the url to the height map
  42800. * @param options defines the options used to create the mesh
  42801. * @param scene defines the hosting scene
  42802. * @returns the ground mesh
  42803. * @see https://doc.babylonjs.com/babylon101/height_map
  42804. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42805. */
  42806. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42807. width?: number;
  42808. height?: number;
  42809. subdivisions?: number;
  42810. minHeight?: number;
  42811. maxHeight?: number;
  42812. colorFilter?: Color3;
  42813. alphaFilter?: number;
  42814. updatable?: boolean;
  42815. onReady?: (mesh: GroundMesh) => void;
  42816. }, scene?: Nullable<Scene>): GroundMesh;
  42817. }
  42818. }
  42819. declare module BABYLON {
  42820. /**
  42821. * Class containing static functions to help procedurally build meshes
  42822. */
  42823. export class TorusBuilder {
  42824. /**
  42825. * Creates a torus mesh
  42826. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42827. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42828. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42830. * * 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
  42831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42832. * @param name defines the name of the mesh
  42833. * @param options defines the options used to create the mesh
  42834. * @param scene defines the hosting scene
  42835. * @returns the torus mesh
  42836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42837. */
  42838. static CreateTorus(name: string, options: {
  42839. diameter?: number;
  42840. thickness?: number;
  42841. tessellation?: number;
  42842. updatable?: boolean;
  42843. sideOrientation?: number;
  42844. frontUVs?: Vector4;
  42845. backUVs?: Vector4;
  42846. }, scene: any): Mesh;
  42847. }
  42848. }
  42849. declare module BABYLON {
  42850. /**
  42851. * Class containing static functions to help procedurally build meshes
  42852. */
  42853. export class CylinderBuilder {
  42854. /**
  42855. * Creates a cylinder or a cone mesh
  42856. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42857. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42858. * * 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.
  42859. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42860. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42861. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42862. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42863. * * 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).
  42864. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42865. * * 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).
  42866. * * 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
  42867. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42868. * * 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
  42869. * * 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.
  42870. * * If `enclose` is false, a ring surface is one element.
  42871. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42872. * * 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
  42873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42874. * * 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
  42875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42876. * @param name defines the name of the mesh
  42877. * @param options defines the options used to create the mesh
  42878. * @param scene defines the hosting scene
  42879. * @returns the cylinder mesh
  42880. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42881. */
  42882. static CreateCylinder(name: string, options: {
  42883. height?: number;
  42884. diameterTop?: number;
  42885. diameterBottom?: number;
  42886. diameter?: number;
  42887. tessellation?: number;
  42888. subdivisions?: number;
  42889. arc?: number;
  42890. faceColors?: Color4[];
  42891. faceUV?: Vector4[];
  42892. updatable?: boolean;
  42893. hasRings?: boolean;
  42894. enclose?: boolean;
  42895. cap?: number;
  42896. sideOrientation?: number;
  42897. frontUVs?: Vector4;
  42898. backUVs?: Vector4;
  42899. }, scene: any): Mesh;
  42900. }
  42901. }
  42902. declare module BABYLON {
  42903. /**
  42904. * States of the webXR experience
  42905. */
  42906. export enum WebXRState {
  42907. /**
  42908. * Transitioning to being in XR mode
  42909. */
  42910. ENTERING_XR = 0,
  42911. /**
  42912. * Transitioning to non XR mode
  42913. */
  42914. EXITING_XR = 1,
  42915. /**
  42916. * In XR mode and presenting
  42917. */
  42918. IN_XR = 2,
  42919. /**
  42920. * Not entered XR mode
  42921. */
  42922. NOT_IN_XR = 3
  42923. }
  42924. /**
  42925. * Abstraction of the XR render target
  42926. */
  42927. export interface WebXRRenderTarget extends IDisposable {
  42928. /**
  42929. * xrpresent context of the canvas which can be used to display/mirror xr content
  42930. */
  42931. canvasContext: WebGLRenderingContext;
  42932. /**
  42933. * xr layer for the canvas
  42934. */
  42935. xrLayer: Nullable<XRWebGLLayer>;
  42936. /**
  42937. * Initializes the xr layer for the session
  42938. * @param xrSession xr session
  42939. * @returns a promise that will resolve once the XR Layer has been created
  42940. */
  42941. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42942. }
  42943. }
  42944. declare module BABYLON {
  42945. /**
  42946. * COnfiguration object for WebXR output canvas
  42947. */
  42948. export class WebXRManagedOutputCanvasOptions {
  42949. /**
  42950. * An optional canvas in case you wish to create it yourself and provide it here.
  42951. * If not provided, a new canvas will be created
  42952. */
  42953. canvasElement?: HTMLCanvasElement;
  42954. /**
  42955. * Options for this XR Layer output
  42956. */
  42957. canvasOptions?: XRWebGLLayerOptions;
  42958. /**
  42959. * CSS styling for a newly created canvas (if not provided)
  42960. */
  42961. newCanvasCssStyle?: string;
  42962. /**
  42963. * Get the default values of the configuration object
  42964. * @returns default values of this configuration object
  42965. */
  42966. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42967. }
  42968. /**
  42969. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42970. */
  42971. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42972. private _options;
  42973. private _canvas;
  42974. private _engine;
  42975. /**
  42976. * Rendering context of the canvas which can be used to display/mirror xr content
  42977. */
  42978. canvasContext: WebGLRenderingContext;
  42979. /**
  42980. * xr layer for the canvas
  42981. */
  42982. xrLayer: Nullable<XRWebGLLayer>;
  42983. /**
  42984. * Initializes the canvas to be added/removed upon entering/exiting xr
  42985. * @param _xrSessionManager The XR Session manager
  42986. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42987. */
  42988. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42989. /**
  42990. * Disposes of the object
  42991. */
  42992. dispose(): void;
  42993. /**
  42994. * Initializes the xr layer for the session
  42995. * @param xrSession xr session
  42996. * @returns a promise that will resolve once the XR Layer has been created
  42997. */
  42998. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42999. private _addCanvas;
  43000. private _removeCanvas;
  43001. private _setManagedOutputCanvas;
  43002. }
  43003. }
  43004. declare module BABYLON {
  43005. /**
  43006. * Manages an XRSession to work with Babylon's engine
  43007. * @see https://doc.babylonjs.com/how_to/webxr
  43008. */
  43009. export class WebXRSessionManager implements IDisposable {
  43010. /** The scene which the session should be created for */
  43011. scene: Scene;
  43012. private _referenceSpace;
  43013. private _rttProvider;
  43014. private _sessionEnded;
  43015. private _xrNavigator;
  43016. private baseLayer;
  43017. /**
  43018. * The base reference space from which the session started. good if you want to reset your
  43019. * reference space
  43020. */
  43021. baseReferenceSpace: XRReferenceSpace;
  43022. /**
  43023. * Current XR frame
  43024. */
  43025. currentFrame: Nullable<XRFrame>;
  43026. /** WebXR timestamp updated every frame */
  43027. currentTimestamp: number;
  43028. /**
  43029. * Used just in case of a failure to initialize an immersive session.
  43030. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43031. */
  43032. defaultHeightCompensation: number;
  43033. /**
  43034. * Fires every time a new xrFrame arrives which can be used to update the camera
  43035. */
  43036. onXRFrameObservable: Observable<XRFrame>;
  43037. /**
  43038. * Fires when the reference space changed
  43039. */
  43040. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43041. /**
  43042. * Fires when the xr session is ended either by the device or manually done
  43043. */
  43044. onXRSessionEnded: Observable<any>;
  43045. /**
  43046. * Fires when the xr session is ended either by the device or manually done
  43047. */
  43048. onXRSessionInit: Observable<XRSession>;
  43049. /**
  43050. * Underlying xr session
  43051. */
  43052. session: XRSession;
  43053. /**
  43054. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43055. * or get the offset the player is currently at.
  43056. */
  43057. viewerReferenceSpace: XRReferenceSpace;
  43058. /**
  43059. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43060. * @param scene The scene which the session should be created for
  43061. */
  43062. constructor(
  43063. /** The scene which the session should be created for */
  43064. scene: Scene);
  43065. /**
  43066. * The current reference space used in this session. This reference space can constantly change!
  43067. * It is mainly used to offset the camera's position.
  43068. */
  43069. get referenceSpace(): XRReferenceSpace;
  43070. /**
  43071. * Set a new reference space and triggers the observable
  43072. */
  43073. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43074. /**
  43075. * Disposes of the session manager
  43076. */
  43077. dispose(): void;
  43078. /**
  43079. * Stops the xrSession and restores the render loop
  43080. * @returns Promise which resolves after it exits XR
  43081. */
  43082. exitXRAsync(): Promise<void>;
  43083. /**
  43084. * Gets the correct render target texture to be rendered this frame for this eye
  43085. * @param eye the eye for which to get the render target
  43086. * @returns the render target for the specified eye
  43087. */
  43088. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43089. /**
  43090. * Creates a WebXRRenderTarget object for the XR session
  43091. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43092. * @param options optional options to provide when creating a new render target
  43093. * @returns a WebXR render target to which the session can render
  43094. */
  43095. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43096. /**
  43097. * Initializes the manager
  43098. * After initialization enterXR can be called to start an XR session
  43099. * @returns Promise which resolves after it is initialized
  43100. */
  43101. initializeAsync(): Promise<void>;
  43102. /**
  43103. * Initializes an xr session
  43104. * @param xrSessionMode mode to initialize
  43105. * @param xrSessionInit defines optional and required values to pass to the session builder
  43106. * @returns a promise which will resolve once the session has been initialized
  43107. */
  43108. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43109. /**
  43110. * Checks if a session would be supported for the creation options specified
  43111. * @param sessionMode session mode to check if supported eg. immersive-vr
  43112. * @returns A Promise that resolves to true if supported and false if not
  43113. */
  43114. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43115. /**
  43116. * Resets the reference space to the one started the session
  43117. */
  43118. resetReferenceSpace(): void;
  43119. /**
  43120. * Starts rendering to the xr layer
  43121. */
  43122. runXRRenderLoop(): void;
  43123. /**
  43124. * Sets the reference space on the xr session
  43125. * @param referenceSpaceType space to set
  43126. * @returns a promise that will resolve once the reference space has been set
  43127. */
  43128. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43129. /**
  43130. * Updates the render state of the session
  43131. * @param state state to set
  43132. * @returns a promise that resolves once the render state has been updated
  43133. */
  43134. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43135. /**
  43136. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43137. * @param sessionMode defines the session to test
  43138. * @returns a promise with boolean as final value
  43139. */
  43140. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43141. private _createRenderTargetTexture;
  43142. }
  43143. }
  43144. declare module BABYLON {
  43145. /**
  43146. * WebXR Camera which holds the views for the xrSession
  43147. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43148. */
  43149. export class WebXRCamera extends FreeCamera {
  43150. private _xrSessionManager;
  43151. private _firstFrame;
  43152. private _referenceQuaternion;
  43153. private _referencedPosition;
  43154. private _xrInvPositionCache;
  43155. private _xrInvQuaternionCache;
  43156. /**
  43157. * Should position compensation execute on first frame.
  43158. * This is used when copying the position from a native (non XR) camera
  43159. */
  43160. compensateOnFirstFrame: boolean;
  43161. /**
  43162. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43163. * @param name the name of the camera
  43164. * @param scene the scene to add the camera to
  43165. * @param _xrSessionManager a constructed xr session manager
  43166. */
  43167. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43168. /**
  43169. * Return the user's height, unrelated to the current ground.
  43170. * This will be the y position of this camera, when ground level is 0.
  43171. */
  43172. get realWorldHeight(): number;
  43173. /** @hidden */
  43174. _updateForDualEyeDebugging(): void;
  43175. /**
  43176. * Sets this camera's transformation based on a non-vr camera
  43177. * @param otherCamera the non-vr camera to copy the transformation from
  43178. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43179. */
  43180. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43181. /**
  43182. * Gets the current instance class name ("WebXRCamera").
  43183. * @returns the class name
  43184. */
  43185. getClassName(): string;
  43186. private _updateFromXRSession;
  43187. private _updateNumberOfRigCameras;
  43188. private _updateReferenceSpace;
  43189. private _updateReferenceSpaceOffset;
  43190. }
  43191. }
  43192. declare module BABYLON {
  43193. /**
  43194. * Defining the interface required for a (webxr) feature
  43195. */
  43196. export interface IWebXRFeature extends IDisposable {
  43197. /**
  43198. * Is this feature attached
  43199. */
  43200. attached: boolean;
  43201. /**
  43202. * Should auto-attach be disabled?
  43203. */
  43204. disableAutoAttach: boolean;
  43205. /**
  43206. * Attach the feature to the session
  43207. * Will usually be called by the features manager
  43208. *
  43209. * @param force should attachment be forced (even when already attached)
  43210. * @returns true if successful.
  43211. */
  43212. attach(force?: boolean): boolean;
  43213. /**
  43214. * Detach the feature from the session
  43215. * Will usually be called by the features manager
  43216. *
  43217. * @returns true if successful.
  43218. */
  43219. detach(): boolean;
  43220. }
  43221. /**
  43222. * A list of the currently available features without referencing them
  43223. */
  43224. export class WebXRFeatureName {
  43225. /**
  43226. * The name of the anchor system feature
  43227. */
  43228. static ANCHOR_SYSTEM: string;
  43229. /**
  43230. * The name of the background remover feature
  43231. */
  43232. static BACKGROUND_REMOVER: string;
  43233. /**
  43234. * The name of the hit test feature
  43235. */
  43236. static HIT_TEST: string;
  43237. /**
  43238. * physics impostors for xr controllers feature
  43239. */
  43240. static PHYSICS_CONTROLLERS: string;
  43241. /**
  43242. * The name of the plane detection feature
  43243. */
  43244. static PLANE_DETECTION: string;
  43245. /**
  43246. * The name of the pointer selection feature
  43247. */
  43248. static POINTER_SELECTION: string;
  43249. /**
  43250. * The name of the teleportation feature
  43251. */
  43252. static TELEPORTATION: string;
  43253. }
  43254. /**
  43255. * Defining the constructor of a feature. Used to register the modules.
  43256. */
  43257. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43258. /**
  43259. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43260. * It is mainly used in AR sessions.
  43261. *
  43262. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43263. */
  43264. export class WebXRFeaturesManager implements IDisposable {
  43265. private _xrSessionManager;
  43266. private static readonly _AvailableFeatures;
  43267. private _features;
  43268. /**
  43269. * constructs a new features manages.
  43270. *
  43271. * @param _xrSessionManager an instance of WebXRSessionManager
  43272. */
  43273. constructor(_xrSessionManager: WebXRSessionManager);
  43274. /**
  43275. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43276. * Mainly used internally.
  43277. *
  43278. * @param featureName the name of the feature to register
  43279. * @param constructorFunction the function used to construct the module
  43280. * @param version the (babylon) version of the module
  43281. * @param stable is that a stable version of this module
  43282. */
  43283. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43284. /**
  43285. * Returns a constructor of a specific feature.
  43286. *
  43287. * @param featureName the name of the feature to construct
  43288. * @param version the version of the feature to load
  43289. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43290. * @param options optional options provided to the module.
  43291. * @returns a function that, when called, will return a new instance of this feature
  43292. */
  43293. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43294. /**
  43295. * Can be used to return the list of features currently registered
  43296. *
  43297. * @returns an Array of available features
  43298. */
  43299. static GetAvailableFeatures(): string[];
  43300. /**
  43301. * Gets the versions available for a specific feature
  43302. * @param featureName the name of the feature
  43303. * @returns an array with the available versions
  43304. */
  43305. static GetAvailableVersions(featureName: string): string[];
  43306. /**
  43307. * Return the latest unstable version of this feature
  43308. * @param featureName the name of the feature to search
  43309. * @returns the version number. if not found will return -1
  43310. */
  43311. static GetLatestVersionOfFeature(featureName: string): number;
  43312. /**
  43313. * Return the latest stable version of this feature
  43314. * @param featureName the name of the feature to search
  43315. * @returns the version number. if not found will return -1
  43316. */
  43317. static GetStableVersionOfFeature(featureName: string): number;
  43318. /**
  43319. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43320. * Can be used during a session to start a feature
  43321. * @param featureName the name of feature to attach
  43322. */
  43323. attachFeature(featureName: string): void;
  43324. /**
  43325. * Can be used inside a session or when the session ends to detach a specific feature
  43326. * @param featureName the name of the feature to detach
  43327. */
  43328. detachFeature(featureName: string): void;
  43329. /**
  43330. * Used to disable an already-enabled feature
  43331. * The feature will be disposed and will be recreated once enabled.
  43332. * @param featureName the feature to disable
  43333. * @returns true if disable was successful
  43334. */
  43335. disableFeature(featureName: string | {
  43336. Name: string;
  43337. }): boolean;
  43338. /**
  43339. * dispose this features manager
  43340. */
  43341. dispose(): void;
  43342. /**
  43343. * 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.
  43344. * 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.
  43345. *
  43346. * @param featureName the name of the feature to load or the class of the feature
  43347. * @param version optional version to load. if not provided the latest version will be enabled
  43348. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43349. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43350. * @returns a new constructed feature or throws an error if feature not found.
  43351. */
  43352. enableFeature(featureName: string | {
  43353. Name: string;
  43354. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43355. /**
  43356. * get the implementation of an enabled feature.
  43357. * @param featureName the name of the feature to load
  43358. * @returns the feature class, if found
  43359. */
  43360. getEnabledFeature(featureName: string): IWebXRFeature;
  43361. /**
  43362. * Get the list of enabled features
  43363. * @returns an array of enabled features
  43364. */
  43365. getEnabledFeatures(): string[];
  43366. }
  43367. }
  43368. declare module BABYLON {
  43369. /**
  43370. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43371. * @see https://doc.babylonjs.com/how_to/webxr
  43372. */
  43373. export class WebXRExperienceHelper implements IDisposable {
  43374. private scene;
  43375. private _nonVRCamera;
  43376. private _originalSceneAutoClear;
  43377. private _supported;
  43378. /**
  43379. * Camera used to render xr content
  43380. */
  43381. camera: WebXRCamera;
  43382. /** A features manager for this xr session */
  43383. featuresManager: WebXRFeaturesManager;
  43384. /**
  43385. * Observers registered here will be triggered after the camera's initial transformation is set
  43386. * This can be used to set a different ground level or an extra rotation.
  43387. *
  43388. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43389. * to the position set after this observable is done executing.
  43390. */
  43391. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43392. /**
  43393. * Fires when the state of the experience helper has changed
  43394. */
  43395. onStateChangedObservable: Observable<WebXRState>;
  43396. /** Session manager used to keep track of xr session */
  43397. sessionManager: WebXRSessionManager;
  43398. /**
  43399. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43400. */
  43401. state: WebXRState;
  43402. /**
  43403. * Creates a WebXRExperienceHelper
  43404. * @param scene The scene the helper should be created in
  43405. */
  43406. private constructor();
  43407. /**
  43408. * Creates the experience helper
  43409. * @param scene the scene to attach the experience helper to
  43410. * @returns a promise for the experience helper
  43411. */
  43412. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43413. /**
  43414. * Disposes of the experience helper
  43415. */
  43416. dispose(): void;
  43417. /**
  43418. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43419. * @param sessionMode options for the XR session
  43420. * @param referenceSpaceType frame of reference of the XR session
  43421. * @param renderTarget the output canvas that will be used to enter XR mode
  43422. * @returns promise that resolves after xr mode has entered
  43423. */
  43424. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43425. /**
  43426. * Exits XR mode and returns the scene to its original state
  43427. * @returns promise that resolves after xr mode has exited
  43428. */
  43429. exitXRAsync(): Promise<void>;
  43430. private _nonXRToXRCamera;
  43431. private _setState;
  43432. }
  43433. }
  43434. declare module BABYLON {
  43435. /**
  43436. * X-Y values for axes in WebXR
  43437. */
  43438. export interface IWebXRMotionControllerAxesValue {
  43439. /**
  43440. * The value of the x axis
  43441. */
  43442. x: number;
  43443. /**
  43444. * The value of the y-axis
  43445. */
  43446. y: number;
  43447. }
  43448. /**
  43449. * changed / previous values for the values of this component
  43450. */
  43451. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43452. /**
  43453. * current (this frame) value
  43454. */
  43455. current: T;
  43456. /**
  43457. * previous (last change) value
  43458. */
  43459. previous: T;
  43460. }
  43461. /**
  43462. * Represents changes in the component between current frame and last values recorded
  43463. */
  43464. export interface IWebXRMotionControllerComponentChanges {
  43465. /**
  43466. * will be populated with previous and current values if axes changed
  43467. */
  43468. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43469. /**
  43470. * will be populated with previous and current values if pressed changed
  43471. */
  43472. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43473. /**
  43474. * will be populated with previous and current values if touched changed
  43475. */
  43476. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43477. /**
  43478. * will be populated with previous and current values if value changed
  43479. */
  43480. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43481. }
  43482. /**
  43483. * This class represents a single component (for example button or thumbstick) of a motion controller
  43484. */
  43485. export class WebXRControllerComponent implements IDisposable {
  43486. /**
  43487. * the id of this component
  43488. */
  43489. id: string;
  43490. /**
  43491. * the type of the component
  43492. */
  43493. type: MotionControllerComponentType;
  43494. private _buttonIndex;
  43495. private _axesIndices;
  43496. private _axes;
  43497. private _changes;
  43498. private _currentValue;
  43499. private _hasChanges;
  43500. private _pressed;
  43501. private _touched;
  43502. /**
  43503. * button component type
  43504. */
  43505. static BUTTON_TYPE: MotionControllerComponentType;
  43506. /**
  43507. * squeeze component type
  43508. */
  43509. static SQUEEZE_TYPE: MotionControllerComponentType;
  43510. /**
  43511. * Thumbstick component type
  43512. */
  43513. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43514. /**
  43515. * Touchpad component type
  43516. */
  43517. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43518. /**
  43519. * trigger component type
  43520. */
  43521. static TRIGGER_TYPE: MotionControllerComponentType;
  43522. /**
  43523. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43524. * the axes data changes
  43525. */
  43526. onAxisValueChangedObservable: Observable<{
  43527. x: number;
  43528. y: number;
  43529. }>;
  43530. /**
  43531. * Observers registered here will be triggered when the state of a button changes
  43532. * State change is either pressed / touched / value
  43533. */
  43534. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43535. /**
  43536. * Creates a new component for a motion controller.
  43537. * It is created by the motion controller itself
  43538. *
  43539. * @param id the id of this component
  43540. * @param type the type of the component
  43541. * @param _buttonIndex index in the buttons array of the gamepad
  43542. * @param _axesIndices indices of the values in the axes array of the gamepad
  43543. */
  43544. constructor(
  43545. /**
  43546. * the id of this component
  43547. */
  43548. id: string,
  43549. /**
  43550. * the type of the component
  43551. */
  43552. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43553. /**
  43554. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43555. */
  43556. get axes(): IWebXRMotionControllerAxesValue;
  43557. /**
  43558. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43559. */
  43560. get changes(): IWebXRMotionControllerComponentChanges;
  43561. /**
  43562. * Return whether or not the component changed the last frame
  43563. */
  43564. get hasChanges(): boolean;
  43565. /**
  43566. * is the button currently pressed
  43567. */
  43568. get pressed(): boolean;
  43569. /**
  43570. * is the button currently touched
  43571. */
  43572. get touched(): boolean;
  43573. /**
  43574. * Get the current value of this component
  43575. */
  43576. get value(): number;
  43577. /**
  43578. * Dispose this component
  43579. */
  43580. dispose(): void;
  43581. /**
  43582. * Are there axes correlating to this component
  43583. * @return true is axes data is available
  43584. */
  43585. isAxes(): boolean;
  43586. /**
  43587. * Is this component a button (hence - pressable)
  43588. * @returns true if can be pressed
  43589. */
  43590. isButton(): boolean;
  43591. /**
  43592. * update this component using the gamepad object it is in. Called on every frame
  43593. * @param nativeController the native gamepad controller object
  43594. */
  43595. update(nativeController: IMinimalMotionControllerObject): void;
  43596. }
  43597. }
  43598. declare module BABYLON {
  43599. /**
  43600. * Class used to represent data loading progression
  43601. */
  43602. export class SceneLoaderProgressEvent {
  43603. /** defines if data length to load can be evaluated */
  43604. readonly lengthComputable: boolean;
  43605. /** defines the loaded data length */
  43606. readonly loaded: number;
  43607. /** defines the data length to load */
  43608. readonly total: number;
  43609. /**
  43610. * Create a new progress event
  43611. * @param lengthComputable defines if data length to load can be evaluated
  43612. * @param loaded defines the loaded data length
  43613. * @param total defines the data length to load
  43614. */
  43615. constructor(
  43616. /** defines if data length to load can be evaluated */
  43617. lengthComputable: boolean,
  43618. /** defines the loaded data length */
  43619. loaded: number,
  43620. /** defines the data length to load */
  43621. total: number);
  43622. /**
  43623. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43624. * @param event defines the source event
  43625. * @returns a new SceneLoaderProgressEvent
  43626. */
  43627. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43628. }
  43629. /**
  43630. * Interface used by SceneLoader plugins to define supported file extensions
  43631. */
  43632. export interface ISceneLoaderPluginExtensions {
  43633. /**
  43634. * Defines the list of supported extensions
  43635. */
  43636. [extension: string]: {
  43637. isBinary: boolean;
  43638. };
  43639. }
  43640. /**
  43641. * Interface used by SceneLoader plugin factory
  43642. */
  43643. export interface ISceneLoaderPluginFactory {
  43644. /**
  43645. * Defines the name of the factory
  43646. */
  43647. name: string;
  43648. /**
  43649. * Function called to create a new plugin
  43650. * @return the new plugin
  43651. */
  43652. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43653. /**
  43654. * The callback that returns true if the data can be directly loaded.
  43655. * @param data string containing the file data
  43656. * @returns if the data can be loaded directly
  43657. */
  43658. canDirectLoad?(data: string): boolean;
  43659. }
  43660. /**
  43661. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43662. */
  43663. export interface ISceneLoaderPluginBase {
  43664. /**
  43665. * The friendly name of this plugin.
  43666. */
  43667. name: string;
  43668. /**
  43669. * The file extensions supported by this plugin.
  43670. */
  43671. extensions: string | ISceneLoaderPluginExtensions;
  43672. /**
  43673. * The callback called when loading from a url.
  43674. * @param scene scene loading this url
  43675. * @param url url to load
  43676. * @param onSuccess callback called when the file successfully loads
  43677. * @param onProgress callback called while file is loading (if the server supports this mode)
  43678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43679. * @param onError callback called when the file fails to load
  43680. * @returns a file request object
  43681. */
  43682. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43683. /**
  43684. * The callback called when loading from a file object.
  43685. * @param scene scene loading this file
  43686. * @param file defines the file to load
  43687. * @param onSuccess defines the callback to call when data is loaded
  43688. * @param onProgress defines the callback to call during loading process
  43689. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43690. * @param onError defines the callback to call when an error occurs
  43691. * @returns a file request object
  43692. */
  43693. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43694. /**
  43695. * The callback that returns true if the data can be directly loaded.
  43696. * @param data string containing the file data
  43697. * @returns if the data can be loaded directly
  43698. */
  43699. canDirectLoad?(data: string): boolean;
  43700. /**
  43701. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43702. * @param scene scene loading this data
  43703. * @param data string containing the data
  43704. * @returns data to pass to the plugin
  43705. */
  43706. directLoad?(scene: Scene, data: string): any;
  43707. /**
  43708. * The callback that allows custom handling of the root url based on the response url.
  43709. * @param rootUrl the original root url
  43710. * @param responseURL the response url if available
  43711. * @returns the new root url
  43712. */
  43713. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43714. }
  43715. /**
  43716. * Interface used to define a SceneLoader plugin
  43717. */
  43718. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43719. /**
  43720. * Import meshes into a scene.
  43721. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43722. * @param scene The scene to import into
  43723. * @param data The data to import
  43724. * @param rootUrl The root url for scene and resources
  43725. * @param meshes The meshes array to import into
  43726. * @param particleSystems The particle systems array to import into
  43727. * @param skeletons The skeletons array to import into
  43728. * @param onError The callback when import fails
  43729. * @returns True if successful or false otherwise
  43730. */
  43731. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43732. /**
  43733. * Load into a scene.
  43734. * @param scene The scene to load into
  43735. * @param data The data to import
  43736. * @param rootUrl The root url for scene and resources
  43737. * @param onError The callback when import fails
  43738. * @returns True if successful or false otherwise
  43739. */
  43740. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43741. /**
  43742. * Load into an asset container.
  43743. * @param scene The scene to load into
  43744. * @param data The data to import
  43745. * @param rootUrl The root url for scene and resources
  43746. * @param onError The callback when import fails
  43747. * @returns The loaded asset container
  43748. */
  43749. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43750. }
  43751. /**
  43752. * Interface used to define an async SceneLoader plugin
  43753. */
  43754. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43755. /**
  43756. * Import meshes into a scene.
  43757. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43758. * @param scene The scene to import into
  43759. * @param data The data to import
  43760. * @param rootUrl The root url for scene and resources
  43761. * @param onProgress The callback when the load progresses
  43762. * @param fileName Defines the name of the file to load
  43763. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43764. */
  43765. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43766. meshes: AbstractMesh[];
  43767. particleSystems: IParticleSystem[];
  43768. skeletons: Skeleton[];
  43769. animationGroups: AnimationGroup[];
  43770. }>;
  43771. /**
  43772. * Load into a scene.
  43773. * @param scene The scene to load into
  43774. * @param data The data to import
  43775. * @param rootUrl The root url for scene and resources
  43776. * @param onProgress The callback when the load progresses
  43777. * @param fileName Defines the name of the file to load
  43778. * @returns Nothing
  43779. */
  43780. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43781. /**
  43782. * Load into an asset container.
  43783. * @param scene The scene to load into
  43784. * @param data The data to import
  43785. * @param rootUrl The root url for scene and resources
  43786. * @param onProgress The callback when the load progresses
  43787. * @param fileName Defines the name of the file to load
  43788. * @returns The loaded asset container
  43789. */
  43790. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43791. }
  43792. /**
  43793. * Mode that determines how to handle old animation groups before loading new ones.
  43794. */
  43795. export enum SceneLoaderAnimationGroupLoadingMode {
  43796. /**
  43797. * Reset all old animations to initial state then dispose them.
  43798. */
  43799. Clean = 0,
  43800. /**
  43801. * Stop all old animations.
  43802. */
  43803. Stop = 1,
  43804. /**
  43805. * Restart old animations from first frame.
  43806. */
  43807. Sync = 2,
  43808. /**
  43809. * Old animations remains untouched.
  43810. */
  43811. NoSync = 3
  43812. }
  43813. /**
  43814. * Class used to load scene from various file formats using registered plugins
  43815. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43816. */
  43817. export class SceneLoader {
  43818. /**
  43819. * No logging while loading
  43820. */
  43821. static readonly NO_LOGGING: number;
  43822. /**
  43823. * Minimal logging while loading
  43824. */
  43825. static readonly MINIMAL_LOGGING: number;
  43826. /**
  43827. * Summary logging while loading
  43828. */
  43829. static readonly SUMMARY_LOGGING: number;
  43830. /**
  43831. * Detailled logging while loading
  43832. */
  43833. static readonly DETAILED_LOGGING: number;
  43834. /**
  43835. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43836. */
  43837. static get ForceFullSceneLoadingForIncremental(): boolean;
  43838. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43839. /**
  43840. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43841. */
  43842. static get ShowLoadingScreen(): boolean;
  43843. static set ShowLoadingScreen(value: boolean);
  43844. /**
  43845. * Defines the current logging level (while loading the scene)
  43846. * @ignorenaming
  43847. */
  43848. static get loggingLevel(): number;
  43849. static set loggingLevel(value: number);
  43850. /**
  43851. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43852. */
  43853. static get CleanBoneMatrixWeights(): boolean;
  43854. static set CleanBoneMatrixWeights(value: boolean);
  43855. /**
  43856. * Event raised when a plugin is used to load a scene
  43857. */
  43858. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43859. private static _registeredPlugins;
  43860. private static _getDefaultPlugin;
  43861. private static _getPluginForExtension;
  43862. private static _getPluginForDirectLoad;
  43863. private static _getPluginForFilename;
  43864. private static _getDirectLoad;
  43865. private static _loadData;
  43866. private static _getFileInfo;
  43867. /**
  43868. * Gets a plugin that can load the given extension
  43869. * @param extension defines the extension to load
  43870. * @returns a plugin or null if none works
  43871. */
  43872. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43873. /**
  43874. * Gets a boolean indicating that the given extension can be loaded
  43875. * @param extension defines the extension to load
  43876. * @returns true if the extension is supported
  43877. */
  43878. static IsPluginForExtensionAvailable(extension: string): boolean;
  43879. /**
  43880. * Adds a new plugin to the list of registered plugins
  43881. * @param plugin defines the plugin to add
  43882. */
  43883. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43884. /**
  43885. * Import meshes into a scene
  43886. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43887. * @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)
  43888. * @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)
  43889. * @param scene the instance of BABYLON.Scene to append to
  43890. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43891. * @param onProgress a callback with a progress event for each file being loaded
  43892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43893. * @param pluginExtension the extension used to determine the plugin
  43894. * @returns The loaded plugin
  43895. */
  43896. 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>;
  43897. /**
  43898. * Import meshes into a scene
  43899. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43900. * @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)
  43901. * @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)
  43902. * @param scene the instance of BABYLON.Scene to append to
  43903. * @param onProgress a callback with a progress event for each file being loaded
  43904. * @param pluginExtension the extension used to determine the plugin
  43905. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43906. */
  43907. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43908. meshes: AbstractMesh[];
  43909. particleSystems: IParticleSystem[];
  43910. skeletons: Skeleton[];
  43911. animationGroups: AnimationGroup[];
  43912. }>;
  43913. /**
  43914. * Load a scene
  43915. * @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)
  43916. * @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)
  43917. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43918. * @param onSuccess a callback with the scene when import succeeds
  43919. * @param onProgress a callback with a progress event for each file being loaded
  43920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43921. * @param pluginExtension the extension used to determine the plugin
  43922. * @returns The loaded plugin
  43923. */
  43924. 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>;
  43925. /**
  43926. * Load a scene
  43927. * @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)
  43928. * @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)
  43929. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43930. * @param onProgress a callback with a progress event for each file being loaded
  43931. * @param pluginExtension the extension used to determine the plugin
  43932. * @returns The loaded scene
  43933. */
  43934. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43935. /**
  43936. * Append a scene
  43937. * @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)
  43938. * @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)
  43939. * @param scene is the instance of BABYLON.Scene to append to
  43940. * @param onSuccess a callback with the scene when import succeeds
  43941. * @param onProgress a callback with a progress event for each file being loaded
  43942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43943. * @param pluginExtension the extension used to determine the plugin
  43944. * @returns The loaded plugin
  43945. */
  43946. 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>;
  43947. /**
  43948. * Append a scene
  43949. * @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)
  43950. * @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)
  43951. * @param scene is the instance of BABYLON.Scene to append to
  43952. * @param onProgress a callback with a progress event for each file being loaded
  43953. * @param pluginExtension the extension used to determine the plugin
  43954. * @returns The given scene
  43955. */
  43956. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43957. /**
  43958. * Load a scene into an asset container
  43959. * @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)
  43960. * @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)
  43961. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43962. * @param onSuccess a callback with the scene when import succeeds
  43963. * @param onProgress a callback with a progress event for each file being loaded
  43964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43965. * @param pluginExtension the extension used to determine the plugin
  43966. * @returns The loaded plugin
  43967. */
  43968. 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>;
  43969. /**
  43970. * Load a scene into an asset container
  43971. * @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)
  43972. * @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)
  43973. * @param scene is the instance of Scene to append to
  43974. * @param onProgress a callback with a progress event for each file being loaded
  43975. * @param pluginExtension the extension used to determine the plugin
  43976. * @returns The loaded asset container
  43977. */
  43978. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43979. /**
  43980. * Import animations from a file into a scene
  43981. * @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)
  43982. * @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)
  43983. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43984. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43985. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43986. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43987. * @param onSuccess a callback with the scene when import succeeds
  43988. * @param onProgress a callback with a progress event for each file being loaded
  43989. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43990. */
  43991. 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;
  43992. /**
  43993. * Import animations from a file into a scene
  43994. * @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)
  43995. * @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)
  43996. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43997. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43998. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43999. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44000. * @param onSuccess a callback with the scene when import succeeds
  44001. * @param onProgress a callback with a progress event for each file being loaded
  44002. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44003. * @returns the updated scene with imported animations
  44004. */
  44005. 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>;
  44006. }
  44007. }
  44008. declare module BABYLON {
  44009. /**
  44010. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44011. */
  44012. export type MotionControllerHandness = "none" | "left" | "right";
  44013. /**
  44014. * The type of components available in motion controllers.
  44015. * This is not the name of the component.
  44016. */
  44017. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44018. /**
  44019. * The state of a controller component
  44020. */
  44021. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44022. /**
  44023. * The schema of motion controller layout.
  44024. * No object will be initialized using this interface
  44025. * This is used just to define the profile.
  44026. */
  44027. export interface IMotionControllerLayout {
  44028. /**
  44029. * Path to load the assets. Usually relative to the base path
  44030. */
  44031. assetPath: string;
  44032. /**
  44033. * Available components (unsorted)
  44034. */
  44035. components: {
  44036. /**
  44037. * A map of component Ids
  44038. */
  44039. [componentId: string]: {
  44040. /**
  44041. * The type of input the component outputs
  44042. */
  44043. type: MotionControllerComponentType;
  44044. /**
  44045. * The indices of this component in the gamepad object
  44046. */
  44047. gamepadIndices: {
  44048. /**
  44049. * Index of button
  44050. */
  44051. button?: number;
  44052. /**
  44053. * If available, index of x-axis
  44054. */
  44055. xAxis?: number;
  44056. /**
  44057. * If available, index of y-axis
  44058. */
  44059. yAxis?: number;
  44060. };
  44061. /**
  44062. * The mesh's root node name
  44063. */
  44064. rootNodeName: string;
  44065. /**
  44066. * Animation definitions for this model
  44067. */
  44068. visualResponses: {
  44069. [stateKey: string]: {
  44070. /**
  44071. * What property will be animated
  44072. */
  44073. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44074. /**
  44075. * What states influence this visual response
  44076. */
  44077. states: MotionControllerComponentStateType[];
  44078. /**
  44079. * Type of animation - movement or visibility
  44080. */
  44081. valueNodeProperty: "transform" | "visibility";
  44082. /**
  44083. * Base node name to move. Its position will be calculated according to the min and max nodes
  44084. */
  44085. valueNodeName?: string;
  44086. /**
  44087. * Minimum movement node
  44088. */
  44089. minNodeName?: string;
  44090. /**
  44091. * Max movement node
  44092. */
  44093. maxNodeName?: string;
  44094. };
  44095. };
  44096. /**
  44097. * If touch enabled, what is the name of node to display user feedback
  44098. */
  44099. touchPointNodeName?: string;
  44100. };
  44101. };
  44102. /**
  44103. * Is it xr standard mapping or not
  44104. */
  44105. gamepadMapping: "" | "xr-standard";
  44106. /**
  44107. * Base root node of this entire model
  44108. */
  44109. rootNodeName: string;
  44110. /**
  44111. * Defines the main button component id
  44112. */
  44113. selectComponentId: string;
  44114. }
  44115. /**
  44116. * A definition for the layout map in the input profile
  44117. */
  44118. export interface IMotionControllerLayoutMap {
  44119. /**
  44120. * Layouts with handness type as a key
  44121. */
  44122. [handness: string]: IMotionControllerLayout;
  44123. }
  44124. /**
  44125. * The XR Input profile schema
  44126. * Profiles can be found here:
  44127. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44128. */
  44129. export interface IMotionControllerProfile {
  44130. /**
  44131. * fallback profiles for this profileId
  44132. */
  44133. fallbackProfileIds: string[];
  44134. /**
  44135. * The layout map, with handness as key
  44136. */
  44137. layouts: IMotionControllerLayoutMap;
  44138. /**
  44139. * The id of this profile
  44140. * correlates to the profile(s) in the xrInput.profiles array
  44141. */
  44142. profileId: string;
  44143. }
  44144. /**
  44145. * A helper-interface for the 3 meshes needed for controller button animation
  44146. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44147. */
  44148. export interface IMotionControllerButtonMeshMap {
  44149. /**
  44150. * the mesh that defines the pressed value mesh position.
  44151. * This is used to find the max-position of this button
  44152. */
  44153. pressedMesh: AbstractMesh;
  44154. /**
  44155. * the mesh that defines the unpressed value mesh position.
  44156. * This is used to find the min (or initial) position of this button
  44157. */
  44158. unpressedMesh: AbstractMesh;
  44159. /**
  44160. * The mesh that will be changed when value changes
  44161. */
  44162. valueMesh: AbstractMesh;
  44163. }
  44164. /**
  44165. * A helper-interface for the 3 meshes needed for controller axis animation.
  44166. * This will be expanded when touchpad animations are fully supported
  44167. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44168. */
  44169. export interface IMotionControllerMeshMap {
  44170. /**
  44171. * the mesh that defines the maximum value mesh position.
  44172. */
  44173. maxMesh?: AbstractMesh;
  44174. /**
  44175. * the mesh that defines the minimum value mesh position.
  44176. */
  44177. minMesh?: AbstractMesh;
  44178. /**
  44179. * The mesh that will be changed when axis value changes
  44180. */
  44181. valueMesh: AbstractMesh;
  44182. }
  44183. /**
  44184. * The elements needed for change-detection of the gamepad objects in motion controllers
  44185. */
  44186. export interface IMinimalMotionControllerObject {
  44187. /**
  44188. * Available axes of this controller
  44189. */
  44190. axes: number[];
  44191. /**
  44192. * An array of available buttons
  44193. */
  44194. buttons: Array<{
  44195. /**
  44196. * Value of the button/trigger
  44197. */
  44198. value: number;
  44199. /**
  44200. * If the button/trigger is currently touched
  44201. */
  44202. touched: boolean;
  44203. /**
  44204. * If the button/trigger is currently pressed
  44205. */
  44206. pressed: boolean;
  44207. }>;
  44208. }
  44209. /**
  44210. * An Abstract Motion controller
  44211. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44212. * Each component has an observable to check for changes in value and state
  44213. */
  44214. export abstract class WebXRAbstractMotionController implements IDisposable {
  44215. protected scene: Scene;
  44216. protected layout: IMotionControllerLayout;
  44217. /**
  44218. * The gamepad object correlating to this controller
  44219. */
  44220. gamepadObject: IMinimalMotionControllerObject;
  44221. /**
  44222. * handness (left/right/none) of this controller
  44223. */
  44224. handness: MotionControllerHandness;
  44225. private _initComponent;
  44226. private _modelReady;
  44227. /**
  44228. * A map of components (WebXRControllerComponent) in this motion controller
  44229. * Components have a ComponentType and can also have both button and axis definitions
  44230. */
  44231. readonly components: {
  44232. [id: string]: WebXRControllerComponent;
  44233. };
  44234. /**
  44235. * Disable the model's animation. Can be set at any time.
  44236. */
  44237. disableAnimation: boolean;
  44238. /**
  44239. * Observers registered here will be triggered when the model of this controller is done loading
  44240. */
  44241. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44242. /**
  44243. * The profile id of this motion controller
  44244. */
  44245. abstract profileId: string;
  44246. /**
  44247. * The root mesh of the model. It is null if the model was not yet initialized
  44248. */
  44249. rootMesh: Nullable<AbstractMesh>;
  44250. /**
  44251. * constructs a new abstract motion controller
  44252. * @param scene the scene to which the model of the controller will be added
  44253. * @param layout The profile layout to load
  44254. * @param gamepadObject The gamepad object correlating to this controller
  44255. * @param handness handness (left/right/none) of this controller
  44256. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44257. */
  44258. constructor(scene: Scene, layout: IMotionControllerLayout,
  44259. /**
  44260. * The gamepad object correlating to this controller
  44261. */
  44262. gamepadObject: IMinimalMotionControllerObject,
  44263. /**
  44264. * handness (left/right/none) of this controller
  44265. */
  44266. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44267. /**
  44268. * Dispose this controller, the model mesh and all its components
  44269. */
  44270. dispose(): void;
  44271. /**
  44272. * Returns all components of specific type
  44273. * @param type the type to search for
  44274. * @return an array of components with this type
  44275. */
  44276. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44277. /**
  44278. * get a component based an its component id as defined in layout.components
  44279. * @param id the id of the component
  44280. * @returns the component correlates to the id or undefined if not found
  44281. */
  44282. getComponent(id: string): WebXRControllerComponent;
  44283. /**
  44284. * Get the list of components available in this motion controller
  44285. * @returns an array of strings correlating to available components
  44286. */
  44287. getComponentIds(): string[];
  44288. /**
  44289. * Get the first component of specific type
  44290. * @param type type of component to find
  44291. * @return a controller component or null if not found
  44292. */
  44293. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44294. /**
  44295. * Get the main (Select) component of this controller as defined in the layout
  44296. * @returns the main component of this controller
  44297. */
  44298. getMainComponent(): WebXRControllerComponent;
  44299. /**
  44300. * Loads the model correlating to this controller
  44301. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44302. * @returns A promise fulfilled with the result of the model loading
  44303. */
  44304. loadModel(): Promise<boolean>;
  44305. /**
  44306. * Update this model using the current XRFrame
  44307. * @param xrFrame the current xr frame to use and update the model
  44308. */
  44309. updateFromXRFrame(xrFrame: XRFrame): void;
  44310. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44311. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44312. /**
  44313. * Moves the axis on the controller mesh based on its current state
  44314. * @param axis the index of the axis
  44315. * @param axisValue the value of the axis which determines the meshes new position
  44316. * @hidden
  44317. */
  44318. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44319. /**
  44320. * Update the model itself with the current frame data
  44321. * @param xrFrame the frame to use for updating the model mesh
  44322. */
  44323. protected updateModel(xrFrame: XRFrame): void;
  44324. /**
  44325. * Get the filename and path for this controller's model
  44326. * @returns a map of filename and path
  44327. */
  44328. protected abstract _getFilenameAndPath(): {
  44329. filename: string;
  44330. path: string;
  44331. };
  44332. /**
  44333. * This function is called before the mesh is loaded. It checks for loading constraints.
  44334. * For example, this function can check if the GLB loader is available
  44335. * If this function returns false, the generic controller will be loaded instead
  44336. * @returns Is the client ready to load the mesh
  44337. */
  44338. protected abstract _getModelLoadingConstraints(): boolean;
  44339. /**
  44340. * This function will be called after the model was successfully loaded and can be used
  44341. * for mesh transformations before it is available for the user
  44342. * @param meshes the loaded meshes
  44343. */
  44344. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44345. /**
  44346. * Set the root mesh for this controller. Important for the WebXR controller class
  44347. * @param meshes the loaded meshes
  44348. */
  44349. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44350. /**
  44351. * A function executed each frame that updates the mesh (if needed)
  44352. * @param xrFrame the current xrFrame
  44353. */
  44354. protected abstract _updateModel(xrFrame: XRFrame): void;
  44355. private _getGenericFilenameAndPath;
  44356. private _getGenericParentMesh;
  44357. }
  44358. }
  44359. declare module BABYLON {
  44360. /**
  44361. * A generic trigger-only motion controller for WebXR
  44362. */
  44363. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44364. /**
  44365. * Static version of the profile id of this controller
  44366. */
  44367. static ProfileId: string;
  44368. profileId: string;
  44369. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44370. protected _getFilenameAndPath(): {
  44371. filename: string;
  44372. path: string;
  44373. };
  44374. protected _getModelLoadingConstraints(): boolean;
  44375. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44376. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44377. protected _updateModel(): void;
  44378. }
  44379. }
  44380. declare module BABYLON {
  44381. /**
  44382. * Class containing static functions to help procedurally build meshes
  44383. */
  44384. export class SphereBuilder {
  44385. /**
  44386. * Creates a sphere mesh
  44387. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44388. * * 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`)
  44389. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44390. * * 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
  44391. * * 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)
  44392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44393. * * 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
  44394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44395. * @param name defines the name of the mesh
  44396. * @param options defines the options used to create the mesh
  44397. * @param scene defines the hosting scene
  44398. * @returns the sphere mesh
  44399. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44400. */
  44401. static CreateSphere(name: string, options: {
  44402. segments?: number;
  44403. diameter?: number;
  44404. diameterX?: number;
  44405. diameterY?: number;
  44406. diameterZ?: number;
  44407. arc?: number;
  44408. slice?: number;
  44409. sideOrientation?: number;
  44410. frontUVs?: Vector4;
  44411. backUVs?: Vector4;
  44412. updatable?: boolean;
  44413. }, scene?: Nullable<Scene>): Mesh;
  44414. }
  44415. }
  44416. declare module BABYLON {
  44417. /**
  44418. * A profiled motion controller has its profile loaded from an online repository.
  44419. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44420. */
  44421. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44422. private _repositoryUrl;
  44423. private _buttonMeshMapping;
  44424. private _touchDots;
  44425. /**
  44426. * The profile ID of this controller. Will be populated when the controller initializes.
  44427. */
  44428. profileId: string;
  44429. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44430. dispose(): void;
  44431. protected _getFilenameAndPath(): {
  44432. filename: string;
  44433. path: string;
  44434. };
  44435. protected _getModelLoadingConstraints(): boolean;
  44436. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44437. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44438. protected _updateModel(_xrFrame: XRFrame): void;
  44439. }
  44440. }
  44441. declare module BABYLON {
  44442. /**
  44443. * A construction function type to create a new controller based on an xrInput object
  44444. */
  44445. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44446. /**
  44447. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44448. *
  44449. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44450. * it should be replaced with auto-loaded controllers.
  44451. *
  44452. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44453. */
  44454. export class WebXRMotionControllerManager {
  44455. private static _AvailableControllers;
  44456. private static _Fallbacks;
  44457. private static _ProfileLoadingPromises;
  44458. private static _ProfilesList;
  44459. /**
  44460. * The base URL of the online controller repository. Can be changed at any time.
  44461. */
  44462. static BaseRepositoryUrl: string;
  44463. /**
  44464. * Which repository gets priority - local or online
  44465. */
  44466. static PrioritizeOnlineRepository: boolean;
  44467. /**
  44468. * Use the online repository, or use only locally-defined controllers
  44469. */
  44470. static UseOnlineRepository: boolean;
  44471. /**
  44472. * Clear the cache used for profile loading and reload when requested again
  44473. */
  44474. static ClearProfilesCache(): void;
  44475. /**
  44476. * Register the default fallbacks.
  44477. * This function is called automatically when this file is imported.
  44478. */
  44479. static DefaultFallbacks(): void;
  44480. /**
  44481. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44482. * @param profileId the profile to which a fallback needs to be found
  44483. * @return an array with corresponding fallback profiles
  44484. */
  44485. static FindFallbackWithProfileId(profileId: string): string[];
  44486. /**
  44487. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44488. * The order of search:
  44489. *
  44490. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44491. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44492. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44493. * 4) return the generic trigger controller if none were found
  44494. *
  44495. * @param xrInput the xrInput to which a new controller is initialized
  44496. * @param scene the scene to which the model will be added
  44497. * @param forceProfile force a certain profile for this controller
  44498. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44499. */
  44500. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44501. /**
  44502. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44503. *
  44504. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44505. *
  44506. * @param type the profile type to register
  44507. * @param constructFunction the function to be called when loading this profile
  44508. */
  44509. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44510. /**
  44511. * Register a fallback to a specific profile.
  44512. * @param profileId the profileId that will receive the fallbacks
  44513. * @param fallbacks A list of fallback profiles
  44514. */
  44515. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44516. /**
  44517. * Will update the list of profiles available in the repository
  44518. * @return a promise that resolves to a map of profiles available online
  44519. */
  44520. static UpdateProfilesList(): Promise<{
  44521. [profile: string]: string;
  44522. }>;
  44523. private static _LoadProfileFromRepository;
  44524. private static _LoadProfilesFromAvailableControllers;
  44525. }
  44526. }
  44527. declare module BABYLON {
  44528. /**
  44529. * Configuration options for the WebXR controller creation
  44530. */
  44531. export interface IWebXRControllerOptions {
  44532. /**
  44533. * Should the controller mesh be animated when a user interacts with it
  44534. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44535. */
  44536. disableMotionControllerAnimation?: boolean;
  44537. /**
  44538. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44539. */
  44540. doNotLoadControllerMesh?: boolean;
  44541. /**
  44542. * Force a specific controller type for this controller.
  44543. * This can be used when creating your own profile or when testing different controllers
  44544. */
  44545. forceControllerProfile?: string;
  44546. }
  44547. /**
  44548. * Represents an XR controller
  44549. */
  44550. export class WebXRInputSource {
  44551. private _scene;
  44552. /** The underlying input source for the controller */
  44553. inputSource: XRInputSource;
  44554. private _options;
  44555. private _tmpQuaternion;
  44556. private _tmpVector;
  44557. private _uniqueId;
  44558. /**
  44559. * 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
  44560. */
  44561. grip?: AbstractMesh;
  44562. /**
  44563. * If available, this is the gamepad object related to this controller.
  44564. * Using this object it is possible to get click events and trackpad changes of the
  44565. * webxr controller that is currently being used.
  44566. */
  44567. motionController?: WebXRAbstractMotionController;
  44568. /**
  44569. * Event that fires when the controller is removed/disposed.
  44570. * The object provided as event data is this controller, after associated assets were disposed.
  44571. * uniqueId is still available.
  44572. */
  44573. onDisposeObservable: Observable<WebXRInputSource>;
  44574. /**
  44575. * Will be triggered when the mesh associated with the motion controller is done loading.
  44576. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44577. * A shortened version of controller -> motion controller -> on mesh loaded.
  44578. */
  44579. onMeshLoadedObservable: Observable<AbstractMesh>;
  44580. /**
  44581. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44582. */
  44583. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44584. /**
  44585. * Pointer which can be used to select objects or attach a visible laser to
  44586. */
  44587. pointer: AbstractMesh;
  44588. /**
  44589. * Creates the controller
  44590. * @see https://doc.babylonjs.com/how_to/webxr
  44591. * @param _scene the scene which the controller should be associated to
  44592. * @param inputSource the underlying input source for the controller
  44593. * @param _options options for this controller creation
  44594. */
  44595. constructor(_scene: Scene,
  44596. /** The underlying input source for the controller */
  44597. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44598. /**
  44599. * Get this controllers unique id
  44600. */
  44601. get uniqueId(): string;
  44602. /**
  44603. * Disposes of the object
  44604. */
  44605. dispose(): void;
  44606. /**
  44607. * Gets a world space ray coming from the pointer or grip
  44608. * @param result the resulting ray
  44609. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44610. */
  44611. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44612. /**
  44613. * Updates the controller pose based on the given XRFrame
  44614. * @param xrFrame xr frame to update the pose with
  44615. * @param referenceSpace reference space to use
  44616. */
  44617. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44618. }
  44619. }
  44620. declare module BABYLON {
  44621. /**
  44622. * The schema for initialization options of the XR Input class
  44623. */
  44624. export interface IWebXRInputOptions {
  44625. /**
  44626. * If set to true no model will be automatically loaded
  44627. */
  44628. doNotLoadControllerMeshes?: boolean;
  44629. /**
  44630. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44631. * If not found, the xr input profile data will be used.
  44632. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44633. */
  44634. forceInputProfile?: string;
  44635. /**
  44636. * Do not send a request to the controller repository to load the profile.
  44637. *
  44638. * Instead, use the controllers available in babylon itself.
  44639. */
  44640. disableOnlineControllerRepository?: boolean;
  44641. /**
  44642. * A custom URL for the controllers repository
  44643. */
  44644. customControllersRepositoryURL?: string;
  44645. /**
  44646. * Should the controller model's components not move according to the user input
  44647. */
  44648. disableControllerAnimation?: boolean;
  44649. }
  44650. /**
  44651. * XR input used to track XR inputs such as controllers/rays
  44652. */
  44653. export class WebXRInput implements IDisposable {
  44654. /**
  44655. * the xr session manager for this session
  44656. */
  44657. xrSessionManager: WebXRSessionManager;
  44658. /**
  44659. * the WebXR camera for this session. Mainly used for teleportation
  44660. */
  44661. xrCamera: WebXRCamera;
  44662. private readonly options;
  44663. /**
  44664. * XR controllers being tracked
  44665. */
  44666. controllers: Array<WebXRInputSource>;
  44667. private _frameObserver;
  44668. private _sessionEndedObserver;
  44669. private _sessionInitObserver;
  44670. /**
  44671. * Event when a controller has been connected/added
  44672. */
  44673. onControllerAddedObservable: Observable<WebXRInputSource>;
  44674. /**
  44675. * Event when a controller has been removed/disconnected
  44676. */
  44677. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44678. /**
  44679. * Initializes the WebXRInput
  44680. * @param xrSessionManager the xr session manager for this session
  44681. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44682. * @param options = initialization options for this xr input
  44683. */
  44684. constructor(
  44685. /**
  44686. * the xr session manager for this session
  44687. */
  44688. xrSessionManager: WebXRSessionManager,
  44689. /**
  44690. * the WebXR camera for this session. Mainly used for teleportation
  44691. */
  44692. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44693. private _onInputSourcesChange;
  44694. private _addAndRemoveControllers;
  44695. /**
  44696. * Disposes of the object
  44697. */
  44698. dispose(): void;
  44699. }
  44700. }
  44701. declare module BABYLON {
  44702. /**
  44703. * This is the base class for all WebXR features.
  44704. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44705. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44706. */
  44707. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44708. protected _xrSessionManager: WebXRSessionManager;
  44709. private _attached;
  44710. private _removeOnDetach;
  44711. /**
  44712. * Should auto-attach be disabled?
  44713. */
  44714. disableAutoAttach: boolean;
  44715. /**
  44716. * Construct a new (abstract) WebXR feature
  44717. * @param _xrSessionManager the xr session manager for this feature
  44718. */
  44719. constructor(_xrSessionManager: WebXRSessionManager);
  44720. /**
  44721. * Is this feature attached
  44722. */
  44723. get attached(): boolean;
  44724. /**
  44725. * attach this feature
  44726. *
  44727. * @param force should attachment be forced (even when already attached)
  44728. * @returns true if successful, false is failed or already attached
  44729. */
  44730. attach(force?: boolean): boolean;
  44731. /**
  44732. * detach this feature.
  44733. *
  44734. * @returns true if successful, false if failed or already detached
  44735. */
  44736. detach(): boolean;
  44737. /**
  44738. * Dispose this feature and all of the resources attached
  44739. */
  44740. dispose(): void;
  44741. /**
  44742. * This is used to register callbacks that will automatically be removed when detach is called.
  44743. * @param observable the observable to which the observer will be attached
  44744. * @param callback the callback to register
  44745. */
  44746. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44747. /**
  44748. * Code in this function will be executed on each xrFrame received from the browser.
  44749. * This function will not execute after the feature is detached.
  44750. * @param _xrFrame the current frame
  44751. */
  44752. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44753. }
  44754. }
  44755. declare module BABYLON {
  44756. /**
  44757. * Renders a layer on top of an existing scene
  44758. */
  44759. export class UtilityLayerRenderer implements IDisposable {
  44760. /** the original scene that will be rendered on top of */
  44761. originalScene: Scene;
  44762. private _pointerCaptures;
  44763. private _lastPointerEvents;
  44764. private static _DefaultUtilityLayer;
  44765. private static _DefaultKeepDepthUtilityLayer;
  44766. private _sharedGizmoLight;
  44767. private _renderCamera;
  44768. /**
  44769. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44770. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44771. * @returns the camera that is used when rendering the utility layer
  44772. */
  44773. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44774. /**
  44775. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44776. * @param cam the camera that should be used when rendering the utility layer
  44777. */
  44778. setRenderCamera(cam: Nullable<Camera>): void;
  44779. /**
  44780. * @hidden
  44781. * Light which used by gizmos to get light shading
  44782. */
  44783. _getSharedGizmoLight(): HemisphericLight;
  44784. /**
  44785. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44786. */
  44787. pickUtilitySceneFirst: boolean;
  44788. /**
  44789. * 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)
  44790. */
  44791. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44792. /**
  44793. * 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)
  44794. */
  44795. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44796. /**
  44797. * The scene that is rendered on top of the original scene
  44798. */
  44799. utilityLayerScene: Scene;
  44800. /**
  44801. * If the utility layer should automatically be rendered on top of existing scene
  44802. */
  44803. shouldRender: boolean;
  44804. /**
  44805. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44806. */
  44807. onlyCheckPointerDownEvents: boolean;
  44808. /**
  44809. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44810. */
  44811. processAllEvents: boolean;
  44812. /**
  44813. * Observable raised when the pointer move from the utility layer scene to the main scene
  44814. */
  44815. onPointerOutObservable: Observable<number>;
  44816. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44817. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44818. private _afterRenderObserver;
  44819. private _sceneDisposeObserver;
  44820. private _originalPointerObserver;
  44821. /**
  44822. * Instantiates a UtilityLayerRenderer
  44823. * @param originalScene the original scene that will be rendered on top of
  44824. * @param handleEvents boolean indicating if the utility layer should handle events
  44825. */
  44826. constructor(
  44827. /** the original scene that will be rendered on top of */
  44828. originalScene: Scene, handleEvents?: boolean);
  44829. private _notifyObservers;
  44830. /**
  44831. * Renders the utility layers scene on top of the original scene
  44832. */
  44833. render(): void;
  44834. /**
  44835. * Disposes of the renderer
  44836. */
  44837. dispose(): void;
  44838. private _updateCamera;
  44839. }
  44840. }
  44841. declare module BABYLON {
  44842. /**
  44843. * Options interface for the pointer selection module
  44844. */
  44845. export interface IWebXRControllerPointerSelectionOptions {
  44846. /**
  44847. * if provided, this scene will be used to render meshes.
  44848. */
  44849. customUtilityLayerScene?: Scene;
  44850. /**
  44851. * 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)
  44852. * If not disabled, the last picked point will be used to execute a pointer up event
  44853. * If disabled, pointer up event will be triggered right after the pointer down event.
  44854. * Used in screen and gaze target ray mode only
  44855. */
  44856. disablePointerUpOnTouchOut: boolean;
  44857. /**
  44858. * For gaze mode (time to select instead of press)
  44859. */
  44860. forceGazeMode: boolean;
  44861. /**
  44862. * 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
  44863. * to start a new countdown to the pointer down event.
  44864. * Defaults to 1.
  44865. */
  44866. gazeModePointerMovedFactor?: number;
  44867. /**
  44868. * Different button type to use instead of the main component
  44869. */
  44870. overrideButtonId?: string;
  44871. /**
  44872. * use this rendering group id for the meshes (optional)
  44873. */
  44874. renderingGroupId?: number;
  44875. /**
  44876. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44877. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44878. * 3000 means 3 seconds between pointing at something and selecting it
  44879. */
  44880. timeToSelect?: number;
  44881. /**
  44882. * Should meshes created here be added to a utility layer or the main scene
  44883. */
  44884. useUtilityLayer?: boolean;
  44885. /**
  44886. * the xr input to use with this pointer selection
  44887. */
  44888. xrInput: WebXRInput;
  44889. }
  44890. /**
  44891. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44892. */
  44893. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44894. private readonly _options;
  44895. private static _idCounter;
  44896. private _attachController;
  44897. private _controllers;
  44898. private _scene;
  44899. private _tmpVectorForPickCompare;
  44900. /**
  44901. * The module's name
  44902. */
  44903. static readonly Name: string;
  44904. /**
  44905. * The (Babylon) version of this module.
  44906. * This is an integer representing the implementation version.
  44907. * This number does not correspond to the WebXR specs version
  44908. */
  44909. static readonly Version: number;
  44910. /**
  44911. * Disable lighting on the laser pointer (so it will always be visible)
  44912. */
  44913. disablePointerLighting: boolean;
  44914. /**
  44915. * Disable lighting on the selection mesh (so it will always be visible)
  44916. */
  44917. disableSelectionMeshLighting: boolean;
  44918. /**
  44919. * Should the laser pointer be displayed
  44920. */
  44921. displayLaserPointer: boolean;
  44922. /**
  44923. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44924. */
  44925. displaySelectionMesh: boolean;
  44926. /**
  44927. * This color will be set to the laser pointer when selection is triggered
  44928. */
  44929. laserPointerPickedColor: Color3;
  44930. /**
  44931. * Default color of the laser pointer
  44932. */
  44933. lasterPointerDefaultColor: Color3;
  44934. /**
  44935. * default color of the selection ring
  44936. */
  44937. selectionMeshDefaultColor: Color3;
  44938. /**
  44939. * This color will be applied to the selection ring when selection is triggered
  44940. */
  44941. selectionMeshPickedColor: Color3;
  44942. /**
  44943. * Optional filter to be used for ray selection. This predicate shares behavior with
  44944. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44945. */
  44946. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44947. /**
  44948. * constructs a new background remover module
  44949. * @param _xrSessionManager the session manager for this module
  44950. * @param _options read-only options to be used in this module
  44951. */
  44952. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44953. /**
  44954. * attach this feature
  44955. * Will usually be called by the features manager
  44956. *
  44957. * @returns true if successful.
  44958. */
  44959. attach(): boolean;
  44960. /**
  44961. * detach this feature.
  44962. * Will usually be called by the features manager
  44963. *
  44964. * @returns true if successful.
  44965. */
  44966. detach(): boolean;
  44967. /**
  44968. * Will get the mesh under a specific pointer.
  44969. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44970. * @param controllerId the controllerId to check
  44971. * @returns The mesh under pointer or null if no mesh is under the pointer
  44972. */
  44973. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44974. /**
  44975. * Get the xr controller that correlates to the pointer id in the pointer event
  44976. *
  44977. * @param id the pointer id to search for
  44978. * @returns the controller that correlates to this id or null if not found
  44979. */
  44980. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44981. protected _onXRFrame(_xrFrame: XRFrame): void;
  44982. private _attachGazeMode;
  44983. private _attachScreenRayMode;
  44984. private _attachTrackedPointerRayMode;
  44985. private _convertNormalToDirectionOfRay;
  44986. private _detachController;
  44987. private _generateNewMeshPair;
  44988. private _pickingMoved;
  44989. private _updatePointerDistance;
  44990. }
  44991. }
  44992. declare module BABYLON {
  44993. /**
  44994. * Button which can be used to enter a different mode of XR
  44995. */
  44996. export class WebXREnterExitUIButton {
  44997. /** button element */
  44998. element: HTMLElement;
  44999. /** XR initialization options for the button */
  45000. sessionMode: XRSessionMode;
  45001. /** Reference space type */
  45002. referenceSpaceType: XRReferenceSpaceType;
  45003. /**
  45004. * Creates a WebXREnterExitUIButton
  45005. * @param element button element
  45006. * @param sessionMode XR initialization session mode
  45007. * @param referenceSpaceType the type of reference space to be used
  45008. */
  45009. constructor(
  45010. /** button element */
  45011. element: HTMLElement,
  45012. /** XR initialization options for the button */
  45013. sessionMode: XRSessionMode,
  45014. /** Reference space type */
  45015. referenceSpaceType: XRReferenceSpaceType);
  45016. /**
  45017. * Extendable function which can be used to update the button's visuals when the state changes
  45018. * @param activeButton the current active button in the UI
  45019. */
  45020. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45021. }
  45022. /**
  45023. * Options to create the webXR UI
  45024. */
  45025. export class WebXREnterExitUIOptions {
  45026. /**
  45027. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45028. */
  45029. customButtons?: Array<WebXREnterExitUIButton>;
  45030. /**
  45031. * A reference space type to use when creating the default button.
  45032. * Default is local-floor
  45033. */
  45034. referenceSpaceType?: XRReferenceSpaceType;
  45035. /**
  45036. * Context to enter xr with
  45037. */
  45038. renderTarget?: Nullable<WebXRRenderTarget>;
  45039. /**
  45040. * A session mode to use when creating the default button.
  45041. * Default is immersive-vr
  45042. */
  45043. sessionMode?: XRSessionMode;
  45044. }
  45045. /**
  45046. * UI to allow the user to enter/exit XR mode
  45047. */
  45048. export class WebXREnterExitUI implements IDisposable {
  45049. private scene;
  45050. /** version of the options passed to this UI */
  45051. options: WebXREnterExitUIOptions;
  45052. private _activeButton;
  45053. private _buttons;
  45054. private _overlay;
  45055. /**
  45056. * Fired every time the active button is changed.
  45057. *
  45058. * When xr is entered via a button that launches xr that button will be the callback parameter
  45059. *
  45060. * When exiting xr the callback parameter will be null)
  45061. */
  45062. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45063. /**
  45064. *
  45065. * @param scene babylon scene object to use
  45066. * @param options (read-only) version of the options passed to this UI
  45067. */
  45068. private constructor();
  45069. /**
  45070. * Creates UI to allow the user to enter/exit XR mode
  45071. * @param scene the scene to add the ui to
  45072. * @param helper the xr experience helper to enter/exit xr with
  45073. * @param options options to configure the UI
  45074. * @returns the created ui
  45075. */
  45076. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45077. /**
  45078. * Disposes of the XR UI component
  45079. */
  45080. dispose(): void;
  45081. private _updateButtons;
  45082. }
  45083. }
  45084. declare module BABYLON {
  45085. /**
  45086. * Class containing static functions to help procedurally build meshes
  45087. */
  45088. export class LinesBuilder {
  45089. /**
  45090. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45091. * * 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
  45092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45093. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45094. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45095. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45097. * * 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
  45098. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45101. * @param name defines the name of the new line system
  45102. * @param options defines the options used to create the line system
  45103. * @param scene defines the hosting scene
  45104. * @returns a new line system mesh
  45105. */
  45106. static CreateLineSystem(name: string, options: {
  45107. lines: Vector3[][];
  45108. updatable?: boolean;
  45109. instance?: Nullable<LinesMesh>;
  45110. colors?: Nullable<Color4[][]>;
  45111. useVertexAlpha?: boolean;
  45112. }, scene: Nullable<Scene>): LinesMesh;
  45113. /**
  45114. * Creates a line mesh
  45115. * 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
  45116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45117. * * The parameter `points` is an array successive Vector3
  45118. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  45119. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45121. * * When updating an instance, remember that only point positions can change, not the number of points
  45122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45124. * @param name defines the name of the new line system
  45125. * @param options defines the options used to create the line system
  45126. * @param scene defines the hosting scene
  45127. * @returns a new line mesh
  45128. */
  45129. static CreateLines(name: string, options: {
  45130. points: Vector3[];
  45131. updatable?: boolean;
  45132. instance?: Nullable<LinesMesh>;
  45133. colors?: Color4[];
  45134. useVertexAlpha?: boolean;
  45135. }, scene?: Nullable<Scene>): LinesMesh;
  45136. /**
  45137. * Creates a dashed line mesh
  45138. * * 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
  45139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45140. * * The parameter `points` is an array successive Vector3
  45141. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45142. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45143. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45144. * * 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
  45145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45146. * * When updating an instance, remember that only point positions can change, not the number of points
  45147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45148. * @param name defines the name of the mesh
  45149. * @param options defines the options used to create the mesh
  45150. * @param scene defines the hosting scene
  45151. * @returns the dashed line mesh
  45152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45153. */
  45154. static CreateDashedLines(name: string, options: {
  45155. points: Vector3[];
  45156. dashSize?: number;
  45157. gapSize?: number;
  45158. dashNb?: number;
  45159. updatable?: boolean;
  45160. instance?: LinesMesh;
  45161. useVertexAlpha?: boolean;
  45162. }, scene?: Nullable<Scene>): LinesMesh;
  45163. }
  45164. }
  45165. declare module BABYLON {
  45166. /**
  45167. * The options container for the teleportation module
  45168. */
  45169. export interface IWebXRTeleportationOptions {
  45170. /**
  45171. * if provided, this scene will be used to render meshes.
  45172. */
  45173. customUtilityLayerScene?: Scene;
  45174. /**
  45175. * Values to configure the default target mesh
  45176. */
  45177. defaultTargetMeshOptions?: {
  45178. /**
  45179. * Fill color of the teleportation area
  45180. */
  45181. teleportationFillColor?: string;
  45182. /**
  45183. * Border color for the teleportation area
  45184. */
  45185. teleportationBorderColor?: string;
  45186. /**
  45187. * Disable the mesh's animation sequence
  45188. */
  45189. disableAnimation?: boolean;
  45190. /**
  45191. * Disable lighting on the material or the ring and arrow
  45192. */
  45193. disableLighting?: boolean;
  45194. /**
  45195. * Override the default material of the torus and arrow
  45196. */
  45197. torusArrowMaterial?: Material;
  45198. };
  45199. /**
  45200. * A list of meshes to use as floor meshes.
  45201. * Meshes can be added and removed after initializing the feature using the
  45202. * addFloorMesh and removeFloorMesh functions
  45203. * If empty, rotation will still work
  45204. */
  45205. floorMeshes?: AbstractMesh[];
  45206. /**
  45207. * use this rendering group id for the meshes (optional)
  45208. */
  45209. renderingGroupId?: number;
  45210. /**
  45211. * Should teleportation move only to snap points
  45212. */
  45213. snapPointsOnly?: boolean;
  45214. /**
  45215. * An array of points to which the teleportation will snap to.
  45216. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45217. */
  45218. snapPositions?: Vector3[];
  45219. /**
  45220. * How close should the teleportation ray be in order to snap to position.
  45221. * Default to 0.8 units (meters)
  45222. */
  45223. snapToPositionRadius?: number;
  45224. /**
  45225. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45226. * If you want to support rotation, make sure your mesh has a direction indicator.
  45227. *
  45228. * When left untouched, the default mesh will be initialized.
  45229. */
  45230. teleportationTargetMesh?: AbstractMesh;
  45231. /**
  45232. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45233. */
  45234. timeToTeleport?: number;
  45235. /**
  45236. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45237. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45238. */
  45239. useMainComponentOnly?: boolean;
  45240. /**
  45241. * Should meshes created here be added to a utility layer or the main scene
  45242. */
  45243. useUtilityLayer?: boolean;
  45244. /**
  45245. * Babylon XR Input class for controller
  45246. */
  45247. xrInput: WebXRInput;
  45248. }
  45249. /**
  45250. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45251. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45252. * the input of the attached controllers.
  45253. */
  45254. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45255. private _options;
  45256. private _controllers;
  45257. private _currentTeleportationControllerId;
  45258. private _floorMeshes;
  45259. private _quadraticBezierCurve;
  45260. private _selectionFeature;
  45261. private _snapToPositions;
  45262. private _snappedToPoint;
  45263. private _teleportationRingMaterial?;
  45264. private _tmpRay;
  45265. private _tmpVector;
  45266. /**
  45267. * The module's name
  45268. */
  45269. static readonly Name: string;
  45270. /**
  45271. * The (Babylon) version of this module.
  45272. * This is an integer representing the implementation version.
  45273. * This number does not correspond to the webxr specs version
  45274. */
  45275. static readonly Version: number;
  45276. /**
  45277. * Is movement backwards enabled
  45278. */
  45279. backwardsMovementEnabled: boolean;
  45280. /**
  45281. * Distance to travel when moving backwards
  45282. */
  45283. backwardsTeleportationDistance: number;
  45284. /**
  45285. * The distance from the user to the inspection point in the direction of the controller
  45286. * A higher number will allow the user to move further
  45287. * defaults to 5 (meters, in xr units)
  45288. */
  45289. parabolicCheckRadius: number;
  45290. /**
  45291. * Should the module support parabolic ray on top of direct ray
  45292. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45293. * Very helpful when moving between floors / different heights
  45294. */
  45295. parabolicRayEnabled: boolean;
  45296. /**
  45297. * How much rotation should be applied when rotating right and left
  45298. */
  45299. rotationAngle: number;
  45300. /**
  45301. * Is rotation enabled when moving forward?
  45302. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45303. */
  45304. rotationEnabled: boolean;
  45305. /**
  45306. * constructs a new anchor system
  45307. * @param _xrSessionManager an instance of WebXRSessionManager
  45308. * @param _options configuration object for this feature
  45309. */
  45310. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45311. /**
  45312. * Get the snapPointsOnly flag
  45313. */
  45314. get snapPointsOnly(): boolean;
  45315. /**
  45316. * Sets the snapPointsOnly flag
  45317. * @param snapToPoints should teleportation be exclusively to snap points
  45318. */
  45319. set snapPointsOnly(snapToPoints: boolean);
  45320. /**
  45321. * Add a new mesh to the floor meshes array
  45322. * @param mesh the mesh to use as floor mesh
  45323. */
  45324. addFloorMesh(mesh: AbstractMesh): void;
  45325. /**
  45326. * Add a new snap-to point to fix teleportation to this position
  45327. * @param newSnapPoint The new Snap-To point
  45328. */
  45329. addSnapPoint(newSnapPoint: Vector3): void;
  45330. attach(): boolean;
  45331. detach(): boolean;
  45332. dispose(): void;
  45333. /**
  45334. * Remove a mesh from the floor meshes array
  45335. * @param mesh the mesh to remove
  45336. */
  45337. removeFloorMesh(mesh: AbstractMesh): void;
  45338. /**
  45339. * Remove a mesh from the floor meshes array using its name
  45340. * @param name the mesh name to remove
  45341. */
  45342. removeFloorMeshByName(name: string): void;
  45343. /**
  45344. * 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
  45345. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45346. * @returns was the point found and removed or not
  45347. */
  45348. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45349. /**
  45350. * This function sets a selection feature that will be disabled when
  45351. * the forward ray is shown and will be reattached when hidden.
  45352. * This is used to remove the selection rays when moving.
  45353. * @param selectionFeature the feature to disable when forward movement is enabled
  45354. */
  45355. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45356. protected _onXRFrame(_xrFrame: XRFrame): void;
  45357. private _attachController;
  45358. private _createDefaultTargetMesh;
  45359. private _detachController;
  45360. private _findClosestSnapPointWithRadius;
  45361. private _setTargetMeshPosition;
  45362. private _setTargetMeshVisibility;
  45363. private _showParabolicPath;
  45364. private _teleportForward;
  45365. }
  45366. }
  45367. declare module BABYLON {
  45368. /**
  45369. * Options for the default xr helper
  45370. */
  45371. export class WebXRDefaultExperienceOptions {
  45372. /**
  45373. * Enable or disable default UI to enter XR
  45374. */
  45375. disableDefaultUI?: boolean;
  45376. /**
  45377. * Should teleportation not initialize. defaults to false.
  45378. */
  45379. disableTeleportation?: boolean;
  45380. /**
  45381. * Floor meshes that will be used for teleport
  45382. */
  45383. floorMeshes?: Array<AbstractMesh>;
  45384. /**
  45385. * If set to true, the first frame will not be used to reset position
  45386. * The first frame is mainly used when copying transformation from the old camera
  45387. * Mainly used in AR
  45388. */
  45389. ignoreNativeCameraTransformation?: boolean;
  45390. /**
  45391. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45392. */
  45393. inputOptions?: IWebXRInputOptions;
  45394. /**
  45395. * optional configuration for the output canvas
  45396. */
  45397. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45398. /**
  45399. * optional UI options. This can be used among other to change session mode and reference space type
  45400. */
  45401. uiOptions?: WebXREnterExitUIOptions;
  45402. /**
  45403. * When loading teleportation and pointer select, use stable versions instead of latest.
  45404. */
  45405. useStablePlugins?: boolean;
  45406. }
  45407. /**
  45408. * Default experience which provides a similar setup to the previous webVRExperience
  45409. */
  45410. export class WebXRDefaultExperience {
  45411. /**
  45412. * Base experience
  45413. */
  45414. baseExperience: WebXRExperienceHelper;
  45415. /**
  45416. * Enables ui for entering/exiting xr
  45417. */
  45418. enterExitUI: WebXREnterExitUI;
  45419. /**
  45420. * Input experience extension
  45421. */
  45422. input: WebXRInput;
  45423. /**
  45424. * Enables laser pointer and selection
  45425. */
  45426. pointerSelection: WebXRControllerPointerSelection;
  45427. /**
  45428. * Default target xr should render to
  45429. */
  45430. renderTarget: WebXRRenderTarget;
  45431. /**
  45432. * Enables teleportation
  45433. */
  45434. teleportation: WebXRMotionControllerTeleportation;
  45435. private constructor();
  45436. /**
  45437. * Creates the default xr experience
  45438. * @param scene scene
  45439. * @param options options for basic configuration
  45440. * @returns resulting WebXRDefaultExperience
  45441. */
  45442. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45443. /**
  45444. * DIsposes of the experience helper
  45445. */
  45446. dispose(): void;
  45447. }
  45448. }
  45449. declare module BABYLON {
  45450. /**
  45451. * Options to modify the vr teleportation behavior.
  45452. */
  45453. export interface VRTeleportationOptions {
  45454. /**
  45455. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45456. */
  45457. floorMeshName?: string;
  45458. /**
  45459. * A list of meshes to be used as the teleportation floor. (default: empty)
  45460. */
  45461. floorMeshes?: Mesh[];
  45462. /**
  45463. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45464. */
  45465. teleportationMode?: number;
  45466. /**
  45467. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45468. */
  45469. teleportationTime?: number;
  45470. /**
  45471. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45472. */
  45473. teleportationSpeed?: number;
  45474. /**
  45475. * The easing function used in the animation or null for Linear. (default CircleEase)
  45476. */
  45477. easingFunction?: EasingFunction;
  45478. }
  45479. /**
  45480. * Options to modify the vr experience helper's behavior.
  45481. */
  45482. export interface VRExperienceHelperOptions extends WebVROptions {
  45483. /**
  45484. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45485. */
  45486. createDeviceOrientationCamera?: boolean;
  45487. /**
  45488. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45489. */
  45490. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45491. /**
  45492. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45493. */
  45494. laserToggle?: boolean;
  45495. /**
  45496. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45497. */
  45498. floorMeshes?: Mesh[];
  45499. /**
  45500. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45501. */
  45502. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45503. /**
  45504. * Defines if WebXR should be used instead of WebVR (if available)
  45505. */
  45506. useXR?: boolean;
  45507. }
  45508. /**
  45509. * Event containing information after VR has been entered
  45510. */
  45511. export class OnAfterEnteringVRObservableEvent {
  45512. /**
  45513. * If entering vr was successful
  45514. */
  45515. success: boolean;
  45516. }
  45517. /**
  45518. * Helps to quickly add VR support to an existing scene.
  45519. * See http://doc.babylonjs.com/how_to/webvr_helper
  45520. */
  45521. export class VRExperienceHelper {
  45522. /** Options to modify the vr experience helper's behavior. */
  45523. webVROptions: VRExperienceHelperOptions;
  45524. private _scene;
  45525. private _position;
  45526. private _btnVR;
  45527. private _btnVRDisplayed;
  45528. private _webVRsupported;
  45529. private _webVRready;
  45530. private _webVRrequesting;
  45531. private _webVRpresenting;
  45532. private _hasEnteredVR;
  45533. private _fullscreenVRpresenting;
  45534. private _inputElement;
  45535. private _webVRCamera;
  45536. private _vrDeviceOrientationCamera;
  45537. private _deviceOrientationCamera;
  45538. private _existingCamera;
  45539. private _onKeyDown;
  45540. private _onVrDisplayPresentChange;
  45541. private _onVRDisplayChanged;
  45542. private _onVRRequestPresentStart;
  45543. private _onVRRequestPresentComplete;
  45544. /**
  45545. * 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)
  45546. */
  45547. enableGazeEvenWhenNoPointerLock: boolean;
  45548. /**
  45549. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45550. */
  45551. exitVROnDoubleTap: boolean;
  45552. /**
  45553. * Observable raised right before entering VR.
  45554. */
  45555. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45556. /**
  45557. * Observable raised when entering VR has completed.
  45558. */
  45559. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45560. /**
  45561. * Observable raised when exiting VR.
  45562. */
  45563. onExitingVRObservable: Observable<VRExperienceHelper>;
  45564. /**
  45565. * Observable raised when controller mesh is loaded.
  45566. */
  45567. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45568. /** Return this.onEnteringVRObservable
  45569. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45570. */
  45571. get onEnteringVR(): Observable<VRExperienceHelper>;
  45572. /** Return this.onExitingVRObservable
  45573. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45574. */
  45575. get onExitingVR(): Observable<VRExperienceHelper>;
  45576. /** Return this.onControllerMeshLoadedObservable
  45577. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45578. */
  45579. get onControllerMeshLoaded(): Observable<WebVRController>;
  45580. private _rayLength;
  45581. private _useCustomVRButton;
  45582. private _teleportationRequested;
  45583. private _teleportActive;
  45584. private _floorMeshName;
  45585. private _floorMeshesCollection;
  45586. private _teleportationMode;
  45587. private _teleportationTime;
  45588. private _teleportationSpeed;
  45589. private _teleportationEasing;
  45590. private _rotationAllowed;
  45591. private _teleportBackwardsVector;
  45592. private _teleportationTarget;
  45593. private _isDefaultTeleportationTarget;
  45594. private _postProcessMove;
  45595. private _teleportationFillColor;
  45596. private _teleportationBorderColor;
  45597. private _rotationAngle;
  45598. private _haloCenter;
  45599. private _cameraGazer;
  45600. private _padSensibilityUp;
  45601. private _padSensibilityDown;
  45602. private _leftController;
  45603. private _rightController;
  45604. private _gazeColor;
  45605. private _laserColor;
  45606. private _pickedLaserColor;
  45607. private _pickedGazeColor;
  45608. /**
  45609. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45610. */
  45611. onNewMeshSelected: Observable<AbstractMesh>;
  45612. /**
  45613. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45614. * This observable will provide the mesh and the controller used to select the mesh
  45615. */
  45616. onMeshSelectedWithController: Observable<{
  45617. mesh: AbstractMesh;
  45618. controller: WebVRController;
  45619. }>;
  45620. /**
  45621. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45622. */
  45623. onNewMeshPicked: Observable<PickingInfo>;
  45624. private _circleEase;
  45625. /**
  45626. * Observable raised before camera teleportation
  45627. */
  45628. onBeforeCameraTeleport: Observable<Vector3>;
  45629. /**
  45630. * Observable raised after camera teleportation
  45631. */
  45632. onAfterCameraTeleport: Observable<Vector3>;
  45633. /**
  45634. * Observable raised when current selected mesh gets unselected
  45635. */
  45636. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45637. private _raySelectionPredicate;
  45638. /**
  45639. * To be optionaly changed by user to define custom ray selection
  45640. */
  45641. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45642. /**
  45643. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45644. */
  45645. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45646. /**
  45647. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45648. */
  45649. teleportationEnabled: boolean;
  45650. private _defaultHeight;
  45651. private _teleportationInitialized;
  45652. private _interactionsEnabled;
  45653. private _interactionsRequested;
  45654. private _displayGaze;
  45655. private _displayLaserPointer;
  45656. /**
  45657. * The mesh used to display where the user is going to teleport.
  45658. */
  45659. get teleportationTarget(): Mesh;
  45660. /**
  45661. * Sets the mesh to be used to display where the user is going to teleport.
  45662. */
  45663. set teleportationTarget(value: Mesh);
  45664. /**
  45665. * 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
  45666. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45667. * See http://doc.babylonjs.com/resources/baking_transformations
  45668. */
  45669. get gazeTrackerMesh(): Mesh;
  45670. set gazeTrackerMesh(value: Mesh);
  45671. /**
  45672. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45673. */
  45674. updateGazeTrackerScale: boolean;
  45675. /**
  45676. * If the gaze trackers color should be updated when selecting meshes
  45677. */
  45678. updateGazeTrackerColor: boolean;
  45679. /**
  45680. * If the controller laser color should be updated when selecting meshes
  45681. */
  45682. updateControllerLaserColor: boolean;
  45683. /**
  45684. * The gaze tracking mesh corresponding to the left controller
  45685. */
  45686. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45687. /**
  45688. * The gaze tracking mesh corresponding to the right controller
  45689. */
  45690. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45691. /**
  45692. * If the ray of the gaze should be displayed.
  45693. */
  45694. get displayGaze(): boolean;
  45695. /**
  45696. * Sets if the ray of the gaze should be displayed.
  45697. */
  45698. set displayGaze(value: boolean);
  45699. /**
  45700. * If the ray of the LaserPointer should be displayed.
  45701. */
  45702. get displayLaserPointer(): boolean;
  45703. /**
  45704. * Sets if the ray of the LaserPointer should be displayed.
  45705. */
  45706. set displayLaserPointer(value: boolean);
  45707. /**
  45708. * The deviceOrientationCamera used as the camera when not in VR.
  45709. */
  45710. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45711. /**
  45712. * Based on the current WebVR support, returns the current VR camera used.
  45713. */
  45714. get currentVRCamera(): Nullable<Camera>;
  45715. /**
  45716. * The webVRCamera which is used when in VR.
  45717. */
  45718. get webVRCamera(): WebVRFreeCamera;
  45719. /**
  45720. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45721. */
  45722. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45723. /**
  45724. * The html button that is used to trigger entering into VR.
  45725. */
  45726. get vrButton(): Nullable<HTMLButtonElement>;
  45727. private get _teleportationRequestInitiated();
  45728. /**
  45729. * Defines whether or not Pointer lock should be requested when switching to
  45730. * full screen.
  45731. */
  45732. requestPointerLockOnFullScreen: boolean;
  45733. /**
  45734. * If asking to force XR, this will be populated with the default xr experience
  45735. */
  45736. xr: WebXRDefaultExperience;
  45737. /**
  45738. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45739. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45740. */
  45741. xrTestDone: boolean;
  45742. /**
  45743. * Instantiates a VRExperienceHelper.
  45744. * Helps to quickly add VR support to an existing scene.
  45745. * @param scene The scene the VRExperienceHelper belongs to.
  45746. * @param webVROptions Options to modify the vr experience helper's behavior.
  45747. */
  45748. constructor(scene: Scene,
  45749. /** Options to modify the vr experience helper's behavior. */
  45750. webVROptions?: VRExperienceHelperOptions);
  45751. private completeVRInit;
  45752. private _onDefaultMeshLoaded;
  45753. private _onResize;
  45754. private _onFullscreenChange;
  45755. /**
  45756. * Gets a value indicating if we are currently in VR mode.
  45757. */
  45758. get isInVRMode(): boolean;
  45759. private onVrDisplayPresentChange;
  45760. private onVRDisplayChanged;
  45761. private moveButtonToBottomRight;
  45762. private displayVRButton;
  45763. private updateButtonVisibility;
  45764. private _cachedAngularSensibility;
  45765. /**
  45766. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45767. * Otherwise, will use the fullscreen API.
  45768. */
  45769. enterVR(): void;
  45770. /**
  45771. * Attempt to exit VR, or fullscreen.
  45772. */
  45773. exitVR(): void;
  45774. /**
  45775. * The position of the vr experience helper.
  45776. */
  45777. get position(): Vector3;
  45778. /**
  45779. * Sets the position of the vr experience helper.
  45780. */
  45781. set position(value: Vector3);
  45782. /**
  45783. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45784. */
  45785. enableInteractions(): void;
  45786. private get _noControllerIsActive();
  45787. private beforeRender;
  45788. private _isTeleportationFloor;
  45789. /**
  45790. * Adds a floor mesh to be used for teleportation.
  45791. * @param floorMesh the mesh to be used for teleportation.
  45792. */
  45793. addFloorMesh(floorMesh: Mesh): void;
  45794. /**
  45795. * Removes a floor mesh from being used for teleportation.
  45796. * @param floorMesh the mesh to be removed.
  45797. */
  45798. removeFloorMesh(floorMesh: Mesh): void;
  45799. /**
  45800. * Enables interactions and teleportation using the VR controllers and gaze.
  45801. * @param vrTeleportationOptions options to modify teleportation behavior.
  45802. */
  45803. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45804. private _onNewGamepadConnected;
  45805. private _tryEnableInteractionOnController;
  45806. private _onNewGamepadDisconnected;
  45807. private _enableInteractionOnController;
  45808. private _checkTeleportWithRay;
  45809. private _checkRotate;
  45810. private _checkTeleportBackwards;
  45811. private _enableTeleportationOnController;
  45812. private _createTeleportationCircles;
  45813. private _displayTeleportationTarget;
  45814. private _hideTeleportationTarget;
  45815. private _rotateCamera;
  45816. private _moveTeleportationSelectorTo;
  45817. private _workingVector;
  45818. private _workingQuaternion;
  45819. private _workingMatrix;
  45820. /**
  45821. * Time Constant Teleportation Mode
  45822. */
  45823. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45824. /**
  45825. * Speed Constant Teleportation Mode
  45826. */
  45827. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45828. /**
  45829. * Teleports the users feet to the desired location
  45830. * @param location The location where the user's feet should be placed
  45831. */
  45832. teleportCamera(location: Vector3): void;
  45833. private _convertNormalToDirectionOfRay;
  45834. private _castRayAndSelectObject;
  45835. private _notifySelectedMeshUnselected;
  45836. /**
  45837. * Permanently set new colors for the laser pointer
  45838. * @param color the new laser color
  45839. * @param pickedColor the new laser color when picked mesh detected
  45840. */
  45841. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45842. /**
  45843. * Set lighting enabled / disabled on the laser pointer of both controllers
  45844. * @param enabled should the lighting be enabled on the laser pointer
  45845. */
  45846. setLaserLightingState(enabled?: boolean): void;
  45847. /**
  45848. * Permanently set new colors for the gaze pointer
  45849. * @param color the new gaze color
  45850. * @param pickedColor the new gaze color when picked mesh detected
  45851. */
  45852. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45853. /**
  45854. * Sets the color of the laser ray from the vr controllers.
  45855. * @param color new color for the ray.
  45856. */
  45857. changeLaserColor(color: Color3): void;
  45858. /**
  45859. * Sets the color of the ray from the vr headsets gaze.
  45860. * @param color new color for the ray.
  45861. */
  45862. changeGazeColor(color: Color3): void;
  45863. /**
  45864. * Exits VR and disposes of the vr experience helper
  45865. */
  45866. dispose(): void;
  45867. /**
  45868. * Gets the name of the VRExperienceHelper class
  45869. * @returns "VRExperienceHelper"
  45870. */
  45871. getClassName(): string;
  45872. }
  45873. }
  45874. declare module BABYLON {
  45875. /**
  45876. * Contains an array of blocks representing the octree
  45877. */
  45878. export interface IOctreeContainer<T> {
  45879. /**
  45880. * Blocks within the octree
  45881. */
  45882. blocks: Array<OctreeBlock<T>>;
  45883. }
  45884. /**
  45885. * Class used to store a cell in an octree
  45886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45887. */
  45888. export class OctreeBlock<T> {
  45889. /**
  45890. * Gets the content of the current block
  45891. */
  45892. entries: T[];
  45893. /**
  45894. * Gets the list of block children
  45895. */
  45896. blocks: Array<OctreeBlock<T>>;
  45897. private _depth;
  45898. private _maxDepth;
  45899. private _capacity;
  45900. private _minPoint;
  45901. private _maxPoint;
  45902. private _boundingVectors;
  45903. private _creationFunc;
  45904. /**
  45905. * Creates a new block
  45906. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45907. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45908. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45909. * @param depth defines the current depth of this block in the octree
  45910. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45911. * @param creationFunc defines a callback to call when an element is added to the block
  45912. */
  45913. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45914. /**
  45915. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45916. */
  45917. get capacity(): number;
  45918. /**
  45919. * Gets the minimum vector (in world space) of the block's bounding box
  45920. */
  45921. get minPoint(): Vector3;
  45922. /**
  45923. * Gets the maximum vector (in world space) of the block's bounding box
  45924. */
  45925. get maxPoint(): Vector3;
  45926. /**
  45927. * Add a new element to this block
  45928. * @param entry defines the element to add
  45929. */
  45930. addEntry(entry: T): void;
  45931. /**
  45932. * Remove an element from this block
  45933. * @param entry defines the element to remove
  45934. */
  45935. removeEntry(entry: T): void;
  45936. /**
  45937. * Add an array of elements to this block
  45938. * @param entries defines the array of elements to add
  45939. */
  45940. addEntries(entries: T[]): void;
  45941. /**
  45942. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45943. * @param frustumPlanes defines the frustum planes to test
  45944. * @param selection defines the array to store current content if selection is positive
  45945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45946. */
  45947. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45948. /**
  45949. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45950. * @param sphereCenter defines the bounding sphere center
  45951. * @param sphereRadius defines the bounding sphere radius
  45952. * @param selection defines the array to store current content if selection is positive
  45953. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45954. */
  45955. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45956. /**
  45957. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45958. * @param ray defines the ray to test with
  45959. * @param selection defines the array to store current content if selection is positive
  45960. */
  45961. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45962. /**
  45963. * Subdivide the content into child blocks (this block will then be empty)
  45964. */
  45965. createInnerBlocks(): void;
  45966. /**
  45967. * @hidden
  45968. */
  45969. 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;
  45970. }
  45971. }
  45972. declare module BABYLON {
  45973. /**
  45974. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45976. */
  45977. export class Octree<T> {
  45978. /** 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. maxDepth: number;
  45980. /**
  45981. * Blocks within the octree containing objects
  45982. */
  45983. blocks: Array<OctreeBlock<T>>;
  45984. /**
  45985. * Content stored in the octree
  45986. */
  45987. dynamicContent: T[];
  45988. private _maxBlockCapacity;
  45989. private _selectionContent;
  45990. private _creationFunc;
  45991. /**
  45992. * Creates a octree
  45993. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45994. * @param creationFunc function to be used to instatiate the octree
  45995. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45996. * @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.)
  45997. */
  45998. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45999. /** 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.) */
  46000. maxDepth?: number);
  46001. /**
  46002. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46003. * @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);
  46004. * @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);
  46005. * @param entries meshes to be added to the octree blocks
  46006. */
  46007. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46008. /**
  46009. * Adds a mesh to the octree
  46010. * @param entry Mesh to add to the octree
  46011. */
  46012. addMesh(entry: T): void;
  46013. /**
  46014. * Remove an element from the octree
  46015. * @param entry defines the element to remove
  46016. */
  46017. removeMesh(entry: T): void;
  46018. /**
  46019. * Selects an array of meshes within the frustum
  46020. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46021. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46022. * @returns array of meshes within the frustum
  46023. */
  46024. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46025. /**
  46026. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46027. * @param sphereCenter defines the bounding sphere center
  46028. * @param sphereRadius defines the bounding sphere radius
  46029. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46030. * @returns an array of objects that intersect the sphere
  46031. */
  46032. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46033. /**
  46034. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46035. * @param ray defines the ray to test with
  46036. * @returns array of intersected objects
  46037. */
  46038. intersectsRay(ray: Ray): SmartArray<T>;
  46039. /**
  46040. * Adds a mesh into the octree block if it intersects the block
  46041. */
  46042. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46043. /**
  46044. * Adds a submesh into the octree block if it intersects the block
  46045. */
  46046. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46047. }
  46048. }
  46049. declare module BABYLON {
  46050. interface Scene {
  46051. /**
  46052. * @hidden
  46053. * Backing Filed
  46054. */
  46055. _selectionOctree: Octree<AbstractMesh>;
  46056. /**
  46057. * Gets the octree used to boost mesh selection (picking)
  46058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46059. */
  46060. selectionOctree: Octree<AbstractMesh>;
  46061. /**
  46062. * Creates or updates the octree used to boost selection (picking)
  46063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46064. * @param maxCapacity defines the maximum capacity per leaf
  46065. * @param maxDepth defines the maximum depth of the octree
  46066. * @returns an octree of AbstractMesh
  46067. */
  46068. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46069. }
  46070. interface AbstractMesh {
  46071. /**
  46072. * @hidden
  46073. * Backing Field
  46074. */
  46075. _submeshesOctree: Octree<SubMesh>;
  46076. /**
  46077. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46079. * @param maxCapacity defines the maximum size of each block (64 by default)
  46080. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46081. * @returns the new octree
  46082. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46084. */
  46085. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46086. }
  46087. /**
  46088. * Defines the octree scene component responsible to manage any octrees
  46089. * in a given scene.
  46090. */
  46091. export class OctreeSceneComponent {
  46092. /**
  46093. * The component name help to identify the component in the list of scene components.
  46094. */
  46095. readonly name: string;
  46096. /**
  46097. * The scene the component belongs to.
  46098. */
  46099. scene: Scene;
  46100. /**
  46101. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46102. */
  46103. readonly checksIsEnabled: boolean;
  46104. /**
  46105. * Creates a new instance of the component for the given scene
  46106. * @param scene Defines the scene to register the component in
  46107. */
  46108. constructor(scene: Scene);
  46109. /**
  46110. * Registers the component in a given scene
  46111. */
  46112. register(): void;
  46113. /**
  46114. * Return the list of active meshes
  46115. * @returns the list of active meshes
  46116. */
  46117. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46118. /**
  46119. * Return the list of active sub meshes
  46120. * @param mesh The mesh to get the candidates sub meshes from
  46121. * @returns the list of active sub meshes
  46122. */
  46123. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46124. private _tempRay;
  46125. /**
  46126. * Return the list of sub meshes intersecting with a given local ray
  46127. * @param mesh defines the mesh to find the submesh for
  46128. * @param localRay defines the ray in local space
  46129. * @returns the list of intersecting sub meshes
  46130. */
  46131. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46132. /**
  46133. * Return the list of sub meshes colliding with a collider
  46134. * @param mesh defines the mesh to find the submesh for
  46135. * @param collider defines the collider to evaluate the collision against
  46136. * @returns the list of colliding sub meshes
  46137. */
  46138. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46139. /**
  46140. * Rebuilds the elements related to this component in case of
  46141. * context lost for instance.
  46142. */
  46143. rebuild(): void;
  46144. /**
  46145. * Disposes the component and the associated ressources.
  46146. */
  46147. dispose(): void;
  46148. }
  46149. }
  46150. declare module BABYLON {
  46151. /**
  46152. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46153. */
  46154. export class Gizmo implements IDisposable {
  46155. /** The utility layer the gizmo will be added to */
  46156. gizmoLayer: UtilityLayerRenderer;
  46157. /**
  46158. * The root mesh of the gizmo
  46159. */
  46160. _rootMesh: Mesh;
  46161. private _attachedMesh;
  46162. /**
  46163. * Ratio for the scale of the gizmo (Default: 1)
  46164. */
  46165. scaleRatio: number;
  46166. /**
  46167. * If a custom mesh has been set (Default: false)
  46168. */
  46169. protected _customMeshSet: boolean;
  46170. /**
  46171. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46172. * * When set, interactions will be enabled
  46173. */
  46174. get attachedMesh(): Nullable<AbstractMesh>;
  46175. set attachedMesh(value: Nullable<AbstractMesh>);
  46176. /**
  46177. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46178. * @param mesh The mesh to replace the default mesh of the gizmo
  46179. */
  46180. setCustomMesh(mesh: Mesh): void;
  46181. /**
  46182. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46183. */
  46184. updateGizmoRotationToMatchAttachedMesh: boolean;
  46185. /**
  46186. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46187. */
  46188. updateGizmoPositionToMatchAttachedMesh: boolean;
  46189. /**
  46190. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46191. */
  46192. updateScale: boolean;
  46193. protected _interactionsEnabled: boolean;
  46194. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46195. private _beforeRenderObserver;
  46196. private _tempVector;
  46197. /**
  46198. * Creates a gizmo
  46199. * @param gizmoLayer The utility layer the gizmo will be added to
  46200. */
  46201. constructor(
  46202. /** The utility layer the gizmo will be added to */
  46203. gizmoLayer?: UtilityLayerRenderer);
  46204. /**
  46205. * Updates the gizmo to match the attached mesh's position/rotation
  46206. */
  46207. protected _update(): void;
  46208. /**
  46209. * Disposes of the gizmo
  46210. */
  46211. dispose(): void;
  46212. }
  46213. }
  46214. declare module BABYLON {
  46215. /**
  46216. * Single plane drag gizmo
  46217. */
  46218. export class PlaneDragGizmo extends Gizmo {
  46219. /**
  46220. * Drag behavior responsible for the gizmos dragging interactions
  46221. */
  46222. dragBehavior: PointerDragBehavior;
  46223. private _pointerObserver;
  46224. /**
  46225. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46226. */
  46227. snapDistance: number;
  46228. /**
  46229. * Event that fires each time the gizmo snaps to a new location.
  46230. * * snapDistance is the the change in distance
  46231. */
  46232. onSnapObservable: Observable<{
  46233. snapDistance: number;
  46234. }>;
  46235. private _plane;
  46236. private _coloredMaterial;
  46237. private _hoverMaterial;
  46238. private _isEnabled;
  46239. private _parent;
  46240. /** @hidden */
  46241. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46242. /** @hidden */
  46243. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46244. /**
  46245. * Creates a PlaneDragGizmo
  46246. * @param gizmoLayer The utility layer the gizmo will be added to
  46247. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46248. * @param color The color of the gizmo
  46249. */
  46250. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46251. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46252. /**
  46253. * If the gizmo is enabled
  46254. */
  46255. set isEnabled(value: boolean);
  46256. get isEnabled(): boolean;
  46257. /**
  46258. * Disposes of the gizmo
  46259. */
  46260. dispose(): void;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /**
  46265. * Gizmo that enables dragging a mesh along 3 axis
  46266. */
  46267. export class PositionGizmo extends Gizmo {
  46268. /**
  46269. * Internal gizmo used for interactions on the x axis
  46270. */
  46271. xGizmo: AxisDragGizmo;
  46272. /**
  46273. * Internal gizmo used for interactions on the y axis
  46274. */
  46275. yGizmo: AxisDragGizmo;
  46276. /**
  46277. * Internal gizmo used for interactions on the z axis
  46278. */
  46279. zGizmo: AxisDragGizmo;
  46280. /**
  46281. * Internal gizmo used for interactions on the yz plane
  46282. */
  46283. xPlaneGizmo: PlaneDragGizmo;
  46284. /**
  46285. * Internal gizmo used for interactions on the xz plane
  46286. */
  46287. yPlaneGizmo: PlaneDragGizmo;
  46288. /**
  46289. * Internal gizmo used for interactions on the xy plane
  46290. */
  46291. zPlaneGizmo: PlaneDragGizmo;
  46292. /**
  46293. * private variables
  46294. */
  46295. private _meshAttached;
  46296. private _updateGizmoRotationToMatchAttachedMesh;
  46297. private _snapDistance;
  46298. private _scaleRatio;
  46299. /** Fires an event when any of it's sub gizmos are dragged */
  46300. onDragStartObservable: Observable<unknown>;
  46301. /** Fires an event when any of it's sub gizmos are released from dragging */
  46302. onDragEndObservable: Observable<unknown>;
  46303. /**
  46304. * If set to true, planar drag is enabled
  46305. */
  46306. private _planarGizmoEnabled;
  46307. get attachedMesh(): Nullable<AbstractMesh>;
  46308. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46309. /**
  46310. * Creates a PositionGizmo
  46311. * @param gizmoLayer The utility layer the gizmo will be added to
  46312. */
  46313. constructor(gizmoLayer?: UtilityLayerRenderer);
  46314. /**
  46315. * If the planar drag gizmo is enabled
  46316. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46317. */
  46318. set planarGizmoEnabled(value: boolean);
  46319. get planarGizmoEnabled(): boolean;
  46320. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46321. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46322. /**
  46323. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46324. */
  46325. set snapDistance(value: number);
  46326. get snapDistance(): number;
  46327. /**
  46328. * Ratio for the scale of the gizmo (Default: 1)
  46329. */
  46330. set scaleRatio(value: number);
  46331. get scaleRatio(): number;
  46332. /**
  46333. * Disposes of the gizmo
  46334. */
  46335. dispose(): void;
  46336. /**
  46337. * CustomMeshes are not supported by this gizmo
  46338. * @param mesh The mesh to replace the default mesh of the gizmo
  46339. */
  46340. setCustomMesh(mesh: Mesh): void;
  46341. }
  46342. }
  46343. declare module BABYLON {
  46344. /**
  46345. * Single axis drag gizmo
  46346. */
  46347. export class AxisDragGizmo extends Gizmo {
  46348. /**
  46349. * Drag behavior responsible for the gizmos dragging interactions
  46350. */
  46351. dragBehavior: PointerDragBehavior;
  46352. private _pointerObserver;
  46353. /**
  46354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46355. */
  46356. snapDistance: number;
  46357. /**
  46358. * Event that fires each time the gizmo snaps to a new location.
  46359. * * snapDistance is the the change in distance
  46360. */
  46361. onSnapObservable: Observable<{
  46362. snapDistance: number;
  46363. }>;
  46364. private _isEnabled;
  46365. private _parent;
  46366. private _arrow;
  46367. private _coloredMaterial;
  46368. private _hoverMaterial;
  46369. /** @hidden */
  46370. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46371. /** @hidden */
  46372. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46373. /**
  46374. * Creates an AxisDragGizmo
  46375. * @param gizmoLayer The utility layer the gizmo will be added to
  46376. * @param dragAxis The axis which the gizmo will be able to drag on
  46377. * @param color The color of the gizmo
  46378. */
  46379. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46380. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46381. /**
  46382. * If the gizmo is enabled
  46383. */
  46384. set isEnabled(value: boolean);
  46385. get isEnabled(): boolean;
  46386. /**
  46387. * Disposes of the gizmo
  46388. */
  46389. dispose(): void;
  46390. }
  46391. }
  46392. declare module BABYLON.Debug {
  46393. /**
  46394. * The Axes viewer will show 3 axes in a specific point in space
  46395. */
  46396. export class AxesViewer {
  46397. private _xAxis;
  46398. private _yAxis;
  46399. private _zAxis;
  46400. private _scaleLinesFactor;
  46401. private _instanced;
  46402. /**
  46403. * Gets the hosting scene
  46404. */
  46405. scene: Scene;
  46406. /**
  46407. * Gets or sets a number used to scale line length
  46408. */
  46409. scaleLines: number;
  46410. /** Gets the node hierarchy used to render x-axis */
  46411. get xAxis(): TransformNode;
  46412. /** Gets the node hierarchy used to render y-axis */
  46413. get yAxis(): TransformNode;
  46414. /** Gets the node hierarchy used to render z-axis */
  46415. get zAxis(): TransformNode;
  46416. /**
  46417. * Creates a new AxesViewer
  46418. * @param scene defines the hosting scene
  46419. * @param scaleLines defines a number used to scale line length (1 by default)
  46420. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46421. * @param xAxis defines the node hierarchy used to render the x-axis
  46422. * @param yAxis defines the node hierarchy used to render the y-axis
  46423. * @param zAxis defines the node hierarchy used to render the z-axis
  46424. */
  46425. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46426. /**
  46427. * Force the viewer to update
  46428. * @param position defines the position of the viewer
  46429. * @param xaxis defines the x axis of the viewer
  46430. * @param yaxis defines the y axis of the viewer
  46431. * @param zaxis defines the z axis of the viewer
  46432. */
  46433. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46434. /**
  46435. * Creates an instance of this axes viewer.
  46436. * @returns a new axes viewer with instanced meshes
  46437. */
  46438. createInstance(): AxesViewer;
  46439. /** Releases resources */
  46440. dispose(): void;
  46441. private static _SetRenderingGroupId;
  46442. }
  46443. }
  46444. declare module BABYLON.Debug {
  46445. /**
  46446. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46447. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46448. */
  46449. export class BoneAxesViewer extends AxesViewer {
  46450. /**
  46451. * Gets or sets the target mesh where to display the axes viewer
  46452. */
  46453. mesh: Nullable<Mesh>;
  46454. /**
  46455. * Gets or sets the target bone where to display the axes viewer
  46456. */
  46457. bone: Nullable<Bone>;
  46458. /** Gets current position */
  46459. pos: Vector3;
  46460. /** Gets direction of X axis */
  46461. xaxis: Vector3;
  46462. /** Gets direction of Y axis */
  46463. yaxis: Vector3;
  46464. /** Gets direction of Z axis */
  46465. zaxis: Vector3;
  46466. /**
  46467. * Creates a new BoneAxesViewer
  46468. * @param scene defines the hosting scene
  46469. * @param bone defines the target bone
  46470. * @param mesh defines the target mesh
  46471. * @param scaleLines defines a scaling factor for line length (1 by default)
  46472. */
  46473. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46474. /**
  46475. * Force the viewer to update
  46476. */
  46477. update(): void;
  46478. /** Releases resources */
  46479. dispose(): void;
  46480. }
  46481. }
  46482. declare module BABYLON {
  46483. /**
  46484. * Interface used to define scene explorer extensibility option
  46485. */
  46486. export interface IExplorerExtensibilityOption {
  46487. /**
  46488. * Define the option label
  46489. */
  46490. label: string;
  46491. /**
  46492. * Defines the action to execute on click
  46493. */
  46494. action: (entity: any) => void;
  46495. }
  46496. /**
  46497. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46498. */
  46499. export interface IExplorerExtensibilityGroup {
  46500. /**
  46501. * Defines a predicate to test if a given type mut be extended
  46502. */
  46503. predicate: (entity: any) => boolean;
  46504. /**
  46505. * Gets the list of options added to a type
  46506. */
  46507. entries: IExplorerExtensibilityOption[];
  46508. }
  46509. /**
  46510. * Interface used to define the options to use to create the Inspector
  46511. */
  46512. export interface IInspectorOptions {
  46513. /**
  46514. * Display in overlay mode (default: false)
  46515. */
  46516. overlay?: boolean;
  46517. /**
  46518. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46519. */
  46520. globalRoot?: HTMLElement;
  46521. /**
  46522. * Display the Scene explorer
  46523. */
  46524. showExplorer?: boolean;
  46525. /**
  46526. * Display the property inspector
  46527. */
  46528. showInspector?: boolean;
  46529. /**
  46530. * Display in embed mode (both panes on the right)
  46531. */
  46532. embedMode?: boolean;
  46533. /**
  46534. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46535. */
  46536. handleResize?: boolean;
  46537. /**
  46538. * Allow the panes to popup (default: true)
  46539. */
  46540. enablePopup?: boolean;
  46541. /**
  46542. * Allow the panes to be closed by users (default: true)
  46543. */
  46544. enableClose?: boolean;
  46545. /**
  46546. * Optional list of extensibility entries
  46547. */
  46548. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46549. /**
  46550. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46551. */
  46552. inspectorURL?: string;
  46553. /**
  46554. * Optional initial tab (default to DebugLayerTab.Properties)
  46555. */
  46556. initialTab?: DebugLayerTab;
  46557. }
  46558. interface Scene {
  46559. /**
  46560. * @hidden
  46561. * Backing field
  46562. */
  46563. _debugLayer: DebugLayer;
  46564. /**
  46565. * Gets the debug layer (aka Inspector) associated with the scene
  46566. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46567. */
  46568. debugLayer: DebugLayer;
  46569. }
  46570. /**
  46571. * Enum of inspector action tab
  46572. */
  46573. export enum DebugLayerTab {
  46574. /**
  46575. * Properties tag (default)
  46576. */
  46577. Properties = 0,
  46578. /**
  46579. * Debug tab
  46580. */
  46581. Debug = 1,
  46582. /**
  46583. * Statistics tab
  46584. */
  46585. Statistics = 2,
  46586. /**
  46587. * Tools tab
  46588. */
  46589. Tools = 3,
  46590. /**
  46591. * Settings tab
  46592. */
  46593. Settings = 4
  46594. }
  46595. /**
  46596. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46597. * what is happening in your scene
  46598. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46599. */
  46600. export class DebugLayer {
  46601. /**
  46602. * Define the url to get the inspector script from.
  46603. * By default it uses the babylonjs CDN.
  46604. * @ignoreNaming
  46605. */
  46606. static InspectorURL: string;
  46607. private _scene;
  46608. private BJSINSPECTOR;
  46609. private _onPropertyChangedObservable?;
  46610. /**
  46611. * Observable triggered when a property is changed through the inspector.
  46612. */
  46613. get onPropertyChangedObservable(): any;
  46614. /**
  46615. * Instantiates a new debug layer.
  46616. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46617. * what is happening in your scene
  46618. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46619. * @param scene Defines the scene to inspect
  46620. */
  46621. constructor(scene: Scene);
  46622. /** Creates the inspector window. */
  46623. private _createInspector;
  46624. /**
  46625. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46626. * @param entity defines the entity to select
  46627. * @param lineContainerTitle defines the specific block to highlight
  46628. */
  46629. select(entity: any, lineContainerTitle?: string): void;
  46630. /** Get the inspector from bundle or global */
  46631. private _getGlobalInspector;
  46632. /**
  46633. * Get if the inspector is visible or not.
  46634. * @returns true if visible otherwise, false
  46635. */
  46636. isVisible(): boolean;
  46637. /**
  46638. * Hide the inspector and close its window.
  46639. */
  46640. hide(): void;
  46641. /**
  46642. * Launch the debugLayer.
  46643. * @param config Define the configuration of the inspector
  46644. * @return a promise fulfilled when the debug layer is visible
  46645. */
  46646. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46647. }
  46648. }
  46649. declare module BABYLON {
  46650. /**
  46651. * Class containing static functions to help procedurally build meshes
  46652. */
  46653. export class BoxBuilder {
  46654. /**
  46655. * Creates a box mesh
  46656. * * The parameter `size` sets the size (float) of each box side (default 1)
  46657. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46658. * * 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)
  46659. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46661. * * 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
  46662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46663. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46664. * @param name defines the name of the mesh
  46665. * @param options defines the options used to create the mesh
  46666. * @param scene defines the hosting scene
  46667. * @returns the box mesh
  46668. */
  46669. static CreateBox(name: string, options: {
  46670. size?: number;
  46671. width?: number;
  46672. height?: number;
  46673. depth?: number;
  46674. faceUV?: Vector4[];
  46675. faceColors?: Color4[];
  46676. sideOrientation?: number;
  46677. frontUVs?: Vector4;
  46678. backUVs?: Vector4;
  46679. wrap?: boolean;
  46680. topBaseAt?: number;
  46681. bottomBaseAt?: number;
  46682. updatable?: boolean;
  46683. }, scene?: Nullable<Scene>): Mesh;
  46684. }
  46685. }
  46686. declare module BABYLON.Debug {
  46687. /**
  46688. * Used to show the physics impostor around the specific mesh
  46689. */
  46690. export class PhysicsViewer {
  46691. /** @hidden */
  46692. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46693. /** @hidden */
  46694. protected _meshes: Array<Nullable<AbstractMesh>>;
  46695. /** @hidden */
  46696. protected _scene: Nullable<Scene>;
  46697. /** @hidden */
  46698. protected _numMeshes: number;
  46699. /** @hidden */
  46700. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46701. private _renderFunction;
  46702. private _utilityLayer;
  46703. private _debugBoxMesh;
  46704. private _debugSphereMesh;
  46705. private _debugCylinderMesh;
  46706. private _debugMaterial;
  46707. private _debugMeshMeshes;
  46708. /**
  46709. * Creates a new PhysicsViewer
  46710. * @param scene defines the hosting scene
  46711. */
  46712. constructor(scene: Scene);
  46713. /** @hidden */
  46714. protected _updateDebugMeshes(): void;
  46715. /**
  46716. * Renders a specified physic impostor
  46717. * @param impostor defines the impostor to render
  46718. * @param targetMesh defines the mesh represented by the impostor
  46719. * @returns the new debug mesh used to render the impostor
  46720. */
  46721. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46722. /**
  46723. * Hides a specified physic impostor
  46724. * @param impostor defines the impostor to hide
  46725. */
  46726. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46727. private _getDebugMaterial;
  46728. private _getDebugBoxMesh;
  46729. private _getDebugSphereMesh;
  46730. private _getDebugCylinderMesh;
  46731. private _getDebugMeshMesh;
  46732. private _getDebugMesh;
  46733. /** Releases all resources */
  46734. dispose(): void;
  46735. }
  46736. }
  46737. declare module BABYLON {
  46738. /**
  46739. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46740. * in order to better appreciate the issue one might have.
  46741. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46742. */
  46743. export class RayHelper {
  46744. /**
  46745. * Defines the ray we are currently tryin to visualize.
  46746. */
  46747. ray: Nullable<Ray>;
  46748. private _renderPoints;
  46749. private _renderLine;
  46750. private _renderFunction;
  46751. private _scene;
  46752. private _updateToMeshFunction;
  46753. private _attachedToMesh;
  46754. private _meshSpaceDirection;
  46755. private _meshSpaceOrigin;
  46756. /**
  46757. * Helper function to create a colored helper in a scene in one line.
  46758. * @param ray Defines the ray we are currently tryin to visualize
  46759. * @param scene Defines the scene the ray is used in
  46760. * @param color Defines the color we want to see the ray in
  46761. * @returns The newly created ray helper.
  46762. */
  46763. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46764. /**
  46765. * Instantiate a new ray helper.
  46766. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46767. * in order to better appreciate the issue one might have.
  46768. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46769. * @param ray Defines the ray we are currently tryin to visualize
  46770. */
  46771. constructor(ray: Ray);
  46772. /**
  46773. * Shows the ray we are willing to debug.
  46774. * @param scene Defines the scene the ray needs to be rendered in
  46775. * @param color Defines the color the ray needs to be rendered in
  46776. */
  46777. show(scene: Scene, color?: Color3): void;
  46778. /**
  46779. * Hides the ray we are debugging.
  46780. */
  46781. hide(): void;
  46782. private _render;
  46783. /**
  46784. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46785. * @param mesh Defines the mesh we want the helper attached to
  46786. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46787. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46788. * @param length Defines the length of the ray
  46789. */
  46790. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46791. /**
  46792. * Detach the ray helper from the mesh it has previously been attached to.
  46793. */
  46794. detachFromMesh(): void;
  46795. private _updateToMesh;
  46796. /**
  46797. * Dispose the helper and release its associated resources.
  46798. */
  46799. dispose(): void;
  46800. }
  46801. }
  46802. declare module BABYLON.Debug {
  46803. /**
  46804. * Class used to render a debug view of a given skeleton
  46805. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46806. */
  46807. export class SkeletonViewer {
  46808. /** defines the skeleton to render */
  46809. skeleton: Skeleton;
  46810. /** defines the mesh attached to the skeleton */
  46811. mesh: AbstractMesh;
  46812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46813. autoUpdateBonesMatrices: boolean;
  46814. /** defines the rendering group id to use with the viewer */
  46815. renderingGroupId: number;
  46816. /** Gets or sets the color used to render the skeleton */
  46817. color: Color3;
  46818. private _scene;
  46819. private _debugLines;
  46820. private _debugMesh;
  46821. private _isEnabled;
  46822. private _renderFunction;
  46823. private _utilityLayer;
  46824. /**
  46825. * Returns the mesh used to render the bones
  46826. */
  46827. get debugMesh(): Nullable<LinesMesh>;
  46828. /**
  46829. * Creates a new SkeletonViewer
  46830. * @param skeleton defines the skeleton to render
  46831. * @param mesh defines the mesh attached to the skeleton
  46832. * @param scene defines the hosting scene
  46833. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46834. * @param renderingGroupId defines the rendering group id to use with the viewer
  46835. */
  46836. constructor(
  46837. /** defines the skeleton to render */
  46838. skeleton: Skeleton,
  46839. /** defines the mesh attached to the skeleton */
  46840. mesh: AbstractMesh, scene: Scene,
  46841. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46842. autoUpdateBonesMatrices?: boolean,
  46843. /** defines the rendering group id to use with the viewer */
  46844. renderingGroupId?: number);
  46845. /** Gets or sets a boolean indicating if the viewer is enabled */
  46846. set isEnabled(value: boolean);
  46847. get isEnabled(): boolean;
  46848. private _getBonePosition;
  46849. private _getLinesForBonesWithLength;
  46850. private _getLinesForBonesNoLength;
  46851. /** Update the viewer to sync with current skeleton state */
  46852. update(): void;
  46853. /** Release associated resources */
  46854. dispose(): void;
  46855. }
  46856. }
  46857. declare module BABYLON {
  46858. /**
  46859. * Options to create the null engine
  46860. */
  46861. export class NullEngineOptions {
  46862. /**
  46863. * Render width (Default: 512)
  46864. */
  46865. renderWidth: number;
  46866. /**
  46867. * Render height (Default: 256)
  46868. */
  46869. renderHeight: number;
  46870. /**
  46871. * Texture size (Default: 512)
  46872. */
  46873. textureSize: number;
  46874. /**
  46875. * If delta time between frames should be constant
  46876. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46877. */
  46878. deterministicLockstep: boolean;
  46879. /**
  46880. * Maximum about of steps between frames (Default: 4)
  46881. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46882. */
  46883. lockstepMaxSteps: number;
  46884. }
  46885. /**
  46886. * The null engine class provides support for headless version of babylon.js.
  46887. * This can be used in server side scenario or for testing purposes
  46888. */
  46889. export class NullEngine extends Engine {
  46890. private _options;
  46891. /**
  46892. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46893. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46894. * @returns true if engine is in deterministic lock step mode
  46895. */
  46896. isDeterministicLockStep(): boolean;
  46897. /**
  46898. * Gets the max steps when engine is running in deterministic lock step
  46899. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46900. * @returns the max steps
  46901. */
  46902. getLockstepMaxSteps(): number;
  46903. /**
  46904. * Gets the current hardware scaling level.
  46905. * By default the hardware scaling level is computed from the window device ratio.
  46906. * 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.
  46907. * @returns a number indicating the current hardware scaling level
  46908. */
  46909. getHardwareScalingLevel(): number;
  46910. constructor(options?: NullEngineOptions);
  46911. /**
  46912. * Creates a vertex buffer
  46913. * @param vertices the data for the vertex buffer
  46914. * @returns the new WebGL static buffer
  46915. */
  46916. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46917. /**
  46918. * Creates a new index buffer
  46919. * @param indices defines the content of the index buffer
  46920. * @param updatable defines if the index buffer must be updatable
  46921. * @returns a new webGL buffer
  46922. */
  46923. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46924. /**
  46925. * Clear the current render buffer or the current render target (if any is set up)
  46926. * @param color defines the color to use
  46927. * @param backBuffer defines if the back buffer must be cleared
  46928. * @param depth defines if the depth buffer must be cleared
  46929. * @param stencil defines if the stencil buffer must be cleared
  46930. */
  46931. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46932. /**
  46933. * Gets the current render width
  46934. * @param useScreen defines if screen size must be used (or the current render target if any)
  46935. * @returns a number defining the current render width
  46936. */
  46937. getRenderWidth(useScreen?: boolean): number;
  46938. /**
  46939. * Gets the current render height
  46940. * @param useScreen defines if screen size must be used (or the current render target if any)
  46941. * @returns a number defining the current render height
  46942. */
  46943. getRenderHeight(useScreen?: boolean): number;
  46944. /**
  46945. * Set the WebGL's viewport
  46946. * @param viewport defines the viewport element to be used
  46947. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46948. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46949. */
  46950. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46951. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46952. /**
  46953. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46954. * @param pipelineContext defines the pipeline context to use
  46955. * @param uniformsNames defines the list of uniform names
  46956. * @returns an array of webGL uniform locations
  46957. */
  46958. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46959. /**
  46960. * Gets the lsit of active attributes for a given webGL program
  46961. * @param pipelineContext defines the pipeline context to use
  46962. * @param attributesNames defines the list of attribute names to get
  46963. * @returns an array of indices indicating the offset of each attribute
  46964. */
  46965. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46966. /**
  46967. * Binds an effect to the webGL context
  46968. * @param effect defines the effect to bind
  46969. */
  46970. bindSamplers(effect: Effect): void;
  46971. /**
  46972. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46973. * @param effect defines the effect to activate
  46974. */
  46975. enableEffect(effect: Effect): void;
  46976. /**
  46977. * Set various states to the webGL context
  46978. * @param culling defines backface culling state
  46979. * @param zOffset defines the value to apply to zOffset (0 by default)
  46980. * @param force defines if states must be applied even if cache is up to date
  46981. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46982. */
  46983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46984. /**
  46985. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46990. /**
  46991. * Set the value of an uniform to an array of int32 (stored as vec2)
  46992. * @param uniform defines the webGL uniform location where to store the value
  46993. * @param array defines the array of int32 to store
  46994. */
  46995. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46996. /**
  46997. * Set the value of an uniform to an array of int32 (stored as vec3)
  46998. * @param uniform defines the webGL uniform location where to store the value
  46999. * @param array defines the array of int32 to store
  47000. */
  47001. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47002. /**
  47003. * Set the value of an uniform to an array of int32 (stored as vec4)
  47004. * @param uniform defines the webGL uniform location where to store the value
  47005. * @param array defines the array of int32 to store
  47006. */
  47007. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47008. /**
  47009. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47014. /**
  47015. * Set the value of an uniform to an array of float32 (stored as vec2)
  47016. * @param uniform defines the webGL uniform location where to store the value
  47017. * @param array defines the array of float32 to store
  47018. */
  47019. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47020. /**
  47021. * Set the value of an uniform to an array of float32 (stored as vec3)
  47022. * @param uniform defines the webGL uniform location where to store the value
  47023. * @param array defines the array of float32 to store
  47024. */
  47025. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47026. /**
  47027. * Set the value of an uniform to an array of float32 (stored as vec4)
  47028. * @param uniform defines the webGL uniform location where to store the value
  47029. * @param array defines the array of float32 to store
  47030. */
  47031. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47032. /**
  47033. * Set the value of an uniform to an array of number
  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. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47038. /**
  47039. * Set the value of an uniform to an array of number (stored as vec2)
  47040. * @param uniform defines the webGL uniform location where to store the value
  47041. * @param array defines the array of number to store
  47042. */
  47043. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47044. /**
  47045. * Set the value of an uniform to an array of number (stored as vec3)
  47046. * @param uniform defines the webGL uniform location where to store the value
  47047. * @param array defines the array of number to store
  47048. */
  47049. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47050. /**
  47051. * Set the value of an uniform to an array of number (stored as vec4)
  47052. * @param uniform defines the webGL uniform location where to store the value
  47053. * @param array defines the array of number to store
  47054. */
  47055. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47056. /**
  47057. * Set the value of an uniform to an array of float32 (stored as matrices)
  47058. * @param uniform defines the webGL uniform location where to store the value
  47059. * @param matrices defines the array of float32 to store
  47060. */
  47061. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47062. /**
  47063. * Set the value of an uniform to a matrix (3x3)
  47064. * @param uniform defines the webGL uniform location where to store the value
  47065. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47066. */
  47067. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47068. /**
  47069. * Set the value of an uniform to a matrix (2x2)
  47070. * @param uniform defines the webGL uniform location where to store the value
  47071. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47072. */
  47073. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47074. /**
  47075. * Set the value of an uniform to a number (float)
  47076. * @param uniform defines the webGL uniform location where to store the value
  47077. * @param value defines the float number to store
  47078. */
  47079. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47080. /**
  47081. * Set the value of an uniform to a vec2
  47082. * @param uniform defines the webGL uniform location where to store the value
  47083. * @param x defines the 1st component of the value
  47084. * @param y defines the 2nd component of the value
  47085. */
  47086. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47087. /**
  47088. * Set the value of an uniform to a vec3
  47089. * @param uniform defines the webGL uniform location where to store the value
  47090. * @param x defines the 1st component of the value
  47091. * @param y defines the 2nd component of the value
  47092. * @param z defines the 3rd component of the value
  47093. */
  47094. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47095. /**
  47096. * Set the value of an uniform to a boolean
  47097. * @param uniform defines the webGL uniform location where to store the value
  47098. * @param bool defines the boolean to store
  47099. */
  47100. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47101. /**
  47102. * Set the value of an uniform to a vec4
  47103. * @param uniform defines the webGL uniform location where to store the value
  47104. * @param x defines the 1st component of the value
  47105. * @param y defines the 2nd component of the value
  47106. * @param z defines the 3rd component of the value
  47107. * @param w defines the 4th component of the value
  47108. */
  47109. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47110. /**
  47111. * Sets the current alpha mode
  47112. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47113. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47115. */
  47116. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47117. /**
  47118. * Bind webGl buffers directly to the webGL context
  47119. * @param vertexBuffers defines the vertex buffer to bind
  47120. * @param indexBuffer defines the index buffer to bind
  47121. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47122. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47123. * @param effect defines the effect associated with the vertex buffer
  47124. */
  47125. bindBuffers(vertexBuffers: {
  47126. [key: string]: VertexBuffer;
  47127. }, indexBuffer: DataBuffer, effect: Effect): void;
  47128. /**
  47129. * Force the entire cache to be cleared
  47130. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47131. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47132. */
  47133. wipeCaches(bruteForce?: boolean): void;
  47134. /**
  47135. * Send a draw order
  47136. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47137. * @param indexStart defines the starting index
  47138. * @param indexCount defines the number of index to draw
  47139. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47140. */
  47141. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47142. /**
  47143. * Draw a list of indexed primitives
  47144. * @param fillMode defines the primitive to use
  47145. * @param indexStart defines the starting index
  47146. * @param indexCount defines the number of index to draw
  47147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47148. */
  47149. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47150. /**
  47151. * Draw a list of unindexed primitives
  47152. * @param fillMode defines the primitive to use
  47153. * @param verticesStart defines the index of first vertex to draw
  47154. * @param verticesCount defines the count of vertices to draw
  47155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47156. */
  47157. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47158. /** @hidden */
  47159. _createTexture(): WebGLTexture;
  47160. /** @hidden */
  47161. _releaseTexture(texture: InternalTexture): void;
  47162. /**
  47163. * Usually called from Texture.ts.
  47164. * Passed information to create a WebGLTexture
  47165. * @param urlArg defines a value which contains one of the following:
  47166. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47167. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47168. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47169. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47170. * @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)
  47171. * @param scene needed for loading to the correct scene
  47172. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47173. * @param onLoad optional callback to be called upon successful completion
  47174. * @param onError optional callback to be called upon failure
  47175. * @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
  47176. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47177. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47178. * @param forcedExtension defines the extension to use to pick the right loader
  47179. * @param mimeType defines an optional mime type
  47180. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47181. */
  47182. 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;
  47183. /**
  47184. * Creates a new render target texture
  47185. * @param size defines the size of the texture
  47186. * @param options defines the options used to create the texture
  47187. * @returns a new render target texture stored in an InternalTexture
  47188. */
  47189. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47190. /**
  47191. * Update the sampling mode of a given texture
  47192. * @param samplingMode defines the required sampling mode
  47193. * @param texture defines the texture to update
  47194. */
  47195. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47196. /**
  47197. * Binds the frame buffer to the specified texture.
  47198. * @param texture The texture to render to or null for the default canvas
  47199. * @param faceIndex The face of the texture to render to in case of cube texture
  47200. * @param requiredWidth The width of the target to render to
  47201. * @param requiredHeight The height of the target to render to
  47202. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47203. * @param lodLevel defines le lod level to bind to the frame buffer
  47204. */
  47205. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47206. /**
  47207. * Unbind the current render target texture from the webGL context
  47208. * @param texture defines the render target texture to unbind
  47209. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47210. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47211. */
  47212. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47213. /**
  47214. * Creates a dynamic vertex buffer
  47215. * @param vertices the data for the dynamic vertex buffer
  47216. * @returns the new WebGL dynamic buffer
  47217. */
  47218. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47219. /**
  47220. * Update the content of a dynamic texture
  47221. * @param texture defines the texture to update
  47222. * @param canvas defines the canvas containing the source
  47223. * @param invertY defines if data must be stored with Y axis inverted
  47224. * @param premulAlpha defines if alpha is stored as premultiplied
  47225. * @param format defines the format of the data
  47226. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47227. */
  47228. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47229. /**
  47230. * Gets a boolean indicating if all created effects are ready
  47231. * @returns true if all effects are ready
  47232. */
  47233. areAllEffectsReady(): boolean;
  47234. /**
  47235. * @hidden
  47236. * Get the current error code of the webGL context
  47237. * @returns the error code
  47238. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47239. */
  47240. getError(): number;
  47241. /** @hidden */
  47242. _getUnpackAlignement(): number;
  47243. /** @hidden */
  47244. _unpackFlipY(value: boolean): void;
  47245. /**
  47246. * Update a dynamic index buffer
  47247. * @param indexBuffer defines the target index buffer
  47248. * @param indices defines the data to update
  47249. * @param offset defines the offset in the target index buffer where update should start
  47250. */
  47251. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47252. /**
  47253. * Updates a dynamic vertex buffer.
  47254. * @param vertexBuffer the vertex buffer to update
  47255. * @param vertices the data used to update the vertex buffer
  47256. * @param byteOffset the byte offset of the data (optional)
  47257. * @param byteLength the byte length of the data (optional)
  47258. */
  47259. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47260. /** @hidden */
  47261. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47262. /** @hidden */
  47263. _bindTexture(channel: number, texture: InternalTexture): void;
  47264. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47265. /**
  47266. * 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
  47267. */
  47268. releaseEffects(): void;
  47269. displayLoadingUI(): void;
  47270. hideLoadingUI(): void;
  47271. /** @hidden */
  47272. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47273. /** @hidden */
  47274. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47275. /** @hidden */
  47276. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47277. /** @hidden */
  47278. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. /**
  47283. * @hidden
  47284. **/
  47285. export class _TimeToken {
  47286. _startTimeQuery: Nullable<WebGLQuery>;
  47287. _endTimeQuery: Nullable<WebGLQuery>;
  47288. _timeElapsedQuery: Nullable<WebGLQuery>;
  47289. _timeElapsedQueryEnded: boolean;
  47290. }
  47291. }
  47292. declare module BABYLON {
  47293. /** @hidden */
  47294. export class _OcclusionDataStorage {
  47295. /** @hidden */
  47296. occlusionInternalRetryCounter: number;
  47297. /** @hidden */
  47298. isOcclusionQueryInProgress: boolean;
  47299. /** @hidden */
  47300. isOccluded: boolean;
  47301. /** @hidden */
  47302. occlusionRetryCount: number;
  47303. /** @hidden */
  47304. occlusionType: number;
  47305. /** @hidden */
  47306. occlusionQueryAlgorithmType: number;
  47307. }
  47308. interface Engine {
  47309. /**
  47310. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47311. * @return the new query
  47312. */
  47313. createQuery(): WebGLQuery;
  47314. /**
  47315. * Delete and release a webGL query
  47316. * @param query defines the query to delete
  47317. * @return the current engine
  47318. */
  47319. deleteQuery(query: WebGLQuery): Engine;
  47320. /**
  47321. * Check if a given query has resolved and got its value
  47322. * @param query defines the query to check
  47323. * @returns true if the query got its value
  47324. */
  47325. isQueryResultAvailable(query: WebGLQuery): boolean;
  47326. /**
  47327. * Gets the value of a given query
  47328. * @param query defines the query to check
  47329. * @returns the value of the query
  47330. */
  47331. getQueryResult(query: WebGLQuery): number;
  47332. /**
  47333. * Initiates an occlusion query
  47334. * @param algorithmType defines the algorithm to use
  47335. * @param query defines the query to use
  47336. * @returns the current engine
  47337. * @see http://doc.babylonjs.com/features/occlusionquery
  47338. */
  47339. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47340. /**
  47341. * Ends an occlusion query
  47342. * @see http://doc.babylonjs.com/features/occlusionquery
  47343. * @param algorithmType defines the algorithm to use
  47344. * @returns the current engine
  47345. */
  47346. endOcclusionQuery(algorithmType: number): Engine;
  47347. /**
  47348. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47349. * Please note that only one query can be issued at a time
  47350. * @returns a time token used to track the time span
  47351. */
  47352. startTimeQuery(): Nullable<_TimeToken>;
  47353. /**
  47354. * Ends a time query
  47355. * @param token defines the token used to measure the time span
  47356. * @returns the time spent (in ns)
  47357. */
  47358. endTimeQuery(token: _TimeToken): int;
  47359. /** @hidden */
  47360. _currentNonTimestampToken: Nullable<_TimeToken>;
  47361. /** @hidden */
  47362. _createTimeQuery(): WebGLQuery;
  47363. /** @hidden */
  47364. _deleteTimeQuery(query: WebGLQuery): void;
  47365. /** @hidden */
  47366. _getGlAlgorithmType(algorithmType: number): number;
  47367. /** @hidden */
  47368. _getTimeQueryResult(query: WebGLQuery): any;
  47369. /** @hidden */
  47370. _getTimeQueryAvailability(query: WebGLQuery): any;
  47371. }
  47372. interface AbstractMesh {
  47373. /**
  47374. * Backing filed
  47375. * @hidden
  47376. */
  47377. __occlusionDataStorage: _OcclusionDataStorage;
  47378. /**
  47379. * Access property
  47380. * @hidden
  47381. */
  47382. _occlusionDataStorage: _OcclusionDataStorage;
  47383. /**
  47384. * 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.
  47385. * The default value is -1 which means don't break the query and wait till the result
  47386. * @see http://doc.babylonjs.com/features/occlusionquery
  47387. */
  47388. occlusionRetryCount: number;
  47389. /**
  47390. * 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:
  47391. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47392. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47393. * * 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.
  47394. * @see http://doc.babylonjs.com/features/occlusionquery
  47395. */
  47396. occlusionType: number;
  47397. /**
  47398. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47399. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47400. * * 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.
  47401. * @see http://doc.babylonjs.com/features/occlusionquery
  47402. */
  47403. occlusionQueryAlgorithmType: number;
  47404. /**
  47405. * 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
  47406. * @see http://doc.babylonjs.com/features/occlusionquery
  47407. */
  47408. isOccluded: boolean;
  47409. /**
  47410. * Flag to check the progress status of the query
  47411. * @see http://doc.babylonjs.com/features/occlusionquery
  47412. */
  47413. isOcclusionQueryInProgress: boolean;
  47414. }
  47415. }
  47416. declare module BABYLON {
  47417. /** @hidden */
  47418. export var _forceTransformFeedbackToBundle: boolean;
  47419. interface Engine {
  47420. /**
  47421. * Creates a webGL transform feedback object
  47422. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47423. * @returns the webGL transform feedback object
  47424. */
  47425. createTransformFeedback(): WebGLTransformFeedback;
  47426. /**
  47427. * Delete a webGL transform feedback object
  47428. * @param value defines the webGL transform feedback object to delete
  47429. */
  47430. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47431. /**
  47432. * Bind a webGL transform feedback object to the webgl context
  47433. * @param value defines the webGL transform feedback object to bind
  47434. */
  47435. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47436. /**
  47437. * Begins a transform feedback operation
  47438. * @param usePoints defines if points or triangles must be used
  47439. */
  47440. beginTransformFeedback(usePoints: boolean): void;
  47441. /**
  47442. * Ends a transform feedback operation
  47443. */
  47444. endTransformFeedback(): void;
  47445. /**
  47446. * Specify the varyings to use with transform feedback
  47447. * @param program defines the associated webGL program
  47448. * @param value defines the list of strings representing the varying names
  47449. */
  47450. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47451. /**
  47452. * Bind a webGL buffer for a transform feedback operation
  47453. * @param value defines the webGL buffer to bind
  47454. */
  47455. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47456. }
  47457. }
  47458. declare module BABYLON {
  47459. /**
  47460. * Creation options of the multi render target texture.
  47461. */
  47462. export interface IMultiRenderTargetOptions {
  47463. /**
  47464. * Define if the texture needs to create mip maps after render.
  47465. */
  47466. generateMipMaps?: boolean;
  47467. /**
  47468. * Define the types of all the draw buffers we want to create
  47469. */
  47470. types?: number[];
  47471. /**
  47472. * Define the sampling modes of all the draw buffers we want to create
  47473. */
  47474. samplingModes?: number[];
  47475. /**
  47476. * Define if a depth buffer is required
  47477. */
  47478. generateDepthBuffer?: boolean;
  47479. /**
  47480. * Define if a stencil buffer is required
  47481. */
  47482. generateStencilBuffer?: boolean;
  47483. /**
  47484. * Define if a depth texture is required instead of a depth buffer
  47485. */
  47486. generateDepthTexture?: boolean;
  47487. /**
  47488. * Define the number of desired draw buffers
  47489. */
  47490. textureCount?: number;
  47491. /**
  47492. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47493. */
  47494. doNotChangeAspectRatio?: boolean;
  47495. /**
  47496. * Define the default type of the buffers we are creating
  47497. */
  47498. defaultType?: number;
  47499. }
  47500. /**
  47501. * A multi render target, like a render target provides the ability to render to a texture.
  47502. * Unlike the render target, it can render to several draw buffers in one draw.
  47503. * This is specially interesting in deferred rendering or for any effects requiring more than
  47504. * just one color from a single pass.
  47505. */
  47506. export class MultiRenderTarget extends RenderTargetTexture {
  47507. private _internalTextures;
  47508. private _textures;
  47509. private _multiRenderTargetOptions;
  47510. /**
  47511. * Get if draw buffers are currently supported by the used hardware and browser.
  47512. */
  47513. get isSupported(): boolean;
  47514. /**
  47515. * Get the list of textures generated by the multi render target.
  47516. */
  47517. get textures(): Texture[];
  47518. /**
  47519. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47520. */
  47521. get depthTexture(): Texture;
  47522. /**
  47523. * Set the wrapping mode on U of all the textures we are rendering to.
  47524. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47525. */
  47526. set wrapU(wrap: number);
  47527. /**
  47528. * Set the wrapping mode on V of all the textures we are rendering to.
  47529. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47530. */
  47531. set wrapV(wrap: number);
  47532. /**
  47533. * Instantiate a new multi render target texture.
  47534. * A multi render target, like a render target provides the ability to render to a texture.
  47535. * Unlike the render target, it can render to several draw buffers in one draw.
  47536. * This is specially interesting in deferred rendering or for any effects requiring more than
  47537. * just one color from a single pass.
  47538. * @param name Define the name of the texture
  47539. * @param size Define the size of the buffers to render to
  47540. * @param count Define the number of target we are rendering into
  47541. * @param scene Define the scene the texture belongs to
  47542. * @param options Define the options used to create the multi render target
  47543. */
  47544. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47545. /** @hidden */
  47546. _rebuild(): void;
  47547. private _createInternalTextures;
  47548. private _createTextures;
  47549. /**
  47550. * Define the number of samples used if MSAA is enabled.
  47551. */
  47552. get samples(): number;
  47553. set samples(value: number);
  47554. /**
  47555. * Resize all the textures in the multi render target.
  47556. * Be carrefull as it will recreate all the data in the new texture.
  47557. * @param size Define the new size
  47558. */
  47559. resize(size: any): void;
  47560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47561. /**
  47562. * Dispose the render targets and their associated resources
  47563. */
  47564. dispose(): void;
  47565. /**
  47566. * Release all the underlying texture used as draw buffers.
  47567. */
  47568. releaseInternalTextures(): void;
  47569. }
  47570. }
  47571. declare module BABYLON {
  47572. interface ThinEngine {
  47573. /**
  47574. * Unbind a list of render target textures from the webGL context
  47575. * This is used only when drawBuffer extension or webGL2 are active
  47576. * @param textures defines the render target textures to unbind
  47577. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47578. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47579. */
  47580. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47581. /**
  47582. * Create a multi render target texture
  47583. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47584. * @param size defines the size of the texture
  47585. * @param options defines the creation options
  47586. * @returns the cube texture as an InternalTexture
  47587. */
  47588. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47589. /**
  47590. * Update the sample count for a given multiple render target texture
  47591. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47592. * @param textures defines the textures to update
  47593. * @param samples defines the sample count to set
  47594. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47595. */
  47596. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47597. }
  47598. }
  47599. declare module BABYLON {
  47600. /**
  47601. * Class used to define an additional view for the engine
  47602. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47603. */
  47604. export class EngineView {
  47605. /** Defines the canvas where to render the view */
  47606. target: HTMLCanvasElement;
  47607. /** Defines an optional camera used to render the view (will use active camera else) */
  47608. camera?: Camera;
  47609. }
  47610. interface Engine {
  47611. /**
  47612. * Gets or sets the HTML element to use for attaching events
  47613. */
  47614. inputElement: Nullable<HTMLElement>;
  47615. /**
  47616. * Gets the current engine view
  47617. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47618. */
  47619. activeView: Nullable<EngineView>;
  47620. /** Gets or sets the list of views */
  47621. views: EngineView[];
  47622. /**
  47623. * Register a new child canvas
  47624. * @param canvas defines the canvas to register
  47625. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47626. * @returns the associated view
  47627. */
  47628. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47629. /**
  47630. * Remove a registered child canvas
  47631. * @param canvas defines the canvas to remove
  47632. * @returns the current engine
  47633. */
  47634. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47635. }
  47636. }
  47637. declare module BABYLON {
  47638. interface Engine {
  47639. /** @hidden */
  47640. _excludedCompressedTextures: string[];
  47641. /** @hidden */
  47642. _textureFormatInUse: string;
  47643. /**
  47644. * Gets the list of texture formats supported
  47645. */
  47646. readonly texturesSupported: Array<string>;
  47647. /**
  47648. * Gets the texture format in use
  47649. */
  47650. readonly textureFormatInUse: Nullable<string>;
  47651. /**
  47652. * Set the compressed texture extensions or file names to skip.
  47653. *
  47654. * @param skippedFiles defines the list of those texture files you want to skip
  47655. * Example: [".dds", ".env", "myfile.png"]
  47656. */
  47657. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47658. /**
  47659. * Set the compressed texture format to use, based on the formats you have, and the formats
  47660. * supported by the hardware / browser.
  47661. *
  47662. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47663. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47664. * to API arguments needed to compressed textures. This puts the burden on the container
  47665. * generator to house the arcane code for determining these for current & future formats.
  47666. *
  47667. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47668. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47669. *
  47670. * Note: The result of this call is not taken into account when a texture is base64.
  47671. *
  47672. * @param formatsAvailable defines the list of those format families you have created
  47673. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47674. *
  47675. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47676. * @returns The extension selected.
  47677. */
  47678. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47679. }
  47680. }
  47681. declare module BABYLON {
  47682. /**
  47683. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47684. */
  47685. export interface CubeMapInfo {
  47686. /**
  47687. * The pixel array for the front face.
  47688. * This is stored in format, left to right, up to down format.
  47689. */
  47690. front: Nullable<ArrayBufferView>;
  47691. /**
  47692. * The pixel array for the back face.
  47693. * This is stored in format, left to right, up to down format.
  47694. */
  47695. back: Nullable<ArrayBufferView>;
  47696. /**
  47697. * The pixel array for the left face.
  47698. * This is stored in format, left to right, up to down format.
  47699. */
  47700. left: Nullable<ArrayBufferView>;
  47701. /**
  47702. * The pixel array for the right face.
  47703. * This is stored in format, left to right, up to down format.
  47704. */
  47705. right: Nullable<ArrayBufferView>;
  47706. /**
  47707. * The pixel array for the up face.
  47708. * This is stored in format, left to right, up to down format.
  47709. */
  47710. up: Nullable<ArrayBufferView>;
  47711. /**
  47712. * The pixel array for the down face.
  47713. * This is stored in format, left to right, up to down format.
  47714. */
  47715. down: Nullable<ArrayBufferView>;
  47716. /**
  47717. * The size of the cubemap stored.
  47718. *
  47719. * Each faces will be size * size pixels.
  47720. */
  47721. size: number;
  47722. /**
  47723. * The format of the texture.
  47724. *
  47725. * RGBA, RGB.
  47726. */
  47727. format: number;
  47728. /**
  47729. * The type of the texture data.
  47730. *
  47731. * UNSIGNED_INT, FLOAT.
  47732. */
  47733. type: number;
  47734. /**
  47735. * Specifies whether the texture is in gamma space.
  47736. */
  47737. gammaSpace: boolean;
  47738. }
  47739. /**
  47740. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47741. */
  47742. export class PanoramaToCubeMapTools {
  47743. private static FACE_FRONT;
  47744. private static FACE_BACK;
  47745. private static FACE_RIGHT;
  47746. private static FACE_LEFT;
  47747. private static FACE_DOWN;
  47748. private static FACE_UP;
  47749. /**
  47750. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47751. *
  47752. * @param float32Array The source data.
  47753. * @param inputWidth The width of the input panorama.
  47754. * @param inputHeight The height of the input panorama.
  47755. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47756. * @return The cubemap data
  47757. */
  47758. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47759. private static CreateCubemapTexture;
  47760. private static CalcProjectionSpherical;
  47761. }
  47762. }
  47763. declare module BABYLON {
  47764. /**
  47765. * Helper class dealing with the extraction of spherical polynomial dataArray
  47766. * from a cube map.
  47767. */
  47768. export class CubeMapToSphericalPolynomialTools {
  47769. private static FileFaces;
  47770. /**
  47771. * Converts a texture to the according Spherical Polynomial data.
  47772. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47773. *
  47774. * @param texture The texture to extract the information from.
  47775. * @return The Spherical Polynomial data.
  47776. */
  47777. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47778. /**
  47779. * Converts a cubemap to the according Spherical Polynomial data.
  47780. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47781. *
  47782. * @param cubeInfo The Cube map to extract the information from.
  47783. * @return The Spherical Polynomial data.
  47784. */
  47785. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. interface BaseTexture {
  47790. /**
  47791. * Get the polynomial representation of the texture data.
  47792. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47793. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47794. */
  47795. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47796. }
  47797. }
  47798. declare module BABYLON {
  47799. /** @hidden */
  47800. export var rgbdEncodePixelShader: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module BABYLON {
  47806. /** @hidden */
  47807. export var rgbdDecodePixelShader: {
  47808. name: string;
  47809. shader: string;
  47810. };
  47811. }
  47812. declare module BABYLON {
  47813. /**
  47814. * Raw texture data and descriptor sufficient for WebGL texture upload
  47815. */
  47816. export interface EnvironmentTextureInfo {
  47817. /**
  47818. * Version of the environment map
  47819. */
  47820. version: number;
  47821. /**
  47822. * Width of image
  47823. */
  47824. width: number;
  47825. /**
  47826. * Irradiance information stored in the file.
  47827. */
  47828. irradiance: any;
  47829. /**
  47830. * Specular information stored in the file.
  47831. */
  47832. specular: any;
  47833. }
  47834. /**
  47835. * Defines One Image in the file. It requires only the position in the file
  47836. * as well as the length.
  47837. */
  47838. interface BufferImageData {
  47839. /**
  47840. * Length of the image data.
  47841. */
  47842. length: number;
  47843. /**
  47844. * Position of the data from the null terminator delimiting the end of the JSON.
  47845. */
  47846. position: number;
  47847. }
  47848. /**
  47849. * Defines the specular data enclosed in the file.
  47850. * This corresponds to the version 1 of the data.
  47851. */
  47852. export interface EnvironmentTextureSpecularInfoV1 {
  47853. /**
  47854. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47855. */
  47856. specularDataPosition?: number;
  47857. /**
  47858. * This contains all the images data needed to reconstruct the cubemap.
  47859. */
  47860. mipmaps: Array<BufferImageData>;
  47861. /**
  47862. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47863. */
  47864. lodGenerationScale: number;
  47865. }
  47866. /**
  47867. * Sets of helpers addressing the serialization and deserialization of environment texture
  47868. * stored in a BabylonJS env file.
  47869. * Those files are usually stored as .env files.
  47870. */
  47871. export class EnvironmentTextureTools {
  47872. /**
  47873. * Magic number identifying the env file.
  47874. */
  47875. private static _MagicBytes;
  47876. /**
  47877. * Gets the environment info from an env file.
  47878. * @param data The array buffer containing the .env bytes.
  47879. * @returns the environment file info (the json header) if successfully parsed.
  47880. */
  47881. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47882. /**
  47883. * Creates an environment texture from a loaded cube texture.
  47884. * @param texture defines the cube texture to convert in env file
  47885. * @return a promise containing the environment data if succesfull.
  47886. */
  47887. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47888. /**
  47889. * Creates a JSON representation of the spherical data.
  47890. * @param texture defines the texture containing the polynomials
  47891. * @return the JSON representation of the spherical info
  47892. */
  47893. private static _CreateEnvTextureIrradiance;
  47894. /**
  47895. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47896. * @param data the image data
  47897. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47898. * @return the views described by info providing access to the underlying buffer
  47899. */
  47900. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47901. /**
  47902. * Uploads the texture info contained in the env file to the GPU.
  47903. * @param texture defines the internal texture to upload to
  47904. * @param data defines the data to load
  47905. * @param info defines the texture info retrieved through the GetEnvInfo method
  47906. * @returns a promise
  47907. */
  47908. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47909. private static _OnImageReadyAsync;
  47910. /**
  47911. * Uploads the levels of image data to the GPU.
  47912. * @param texture defines the internal texture to upload to
  47913. * @param imageData defines the array buffer views of image data [mipmap][face]
  47914. * @returns a promise
  47915. */
  47916. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47917. /**
  47918. * Uploads spherical polynomials information to the texture.
  47919. * @param texture defines the texture we are trying to upload the information to
  47920. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47921. */
  47922. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47923. /** @hidden */
  47924. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47925. }
  47926. }
  47927. declare module BABYLON {
  47928. /**
  47929. * Contains position and normal vectors for a vertex
  47930. */
  47931. export class PositionNormalVertex {
  47932. /** the position of the vertex (defaut: 0,0,0) */
  47933. position: Vector3;
  47934. /** the normal of the vertex (defaut: 0,1,0) */
  47935. normal: Vector3;
  47936. /**
  47937. * Creates a PositionNormalVertex
  47938. * @param position the position of the vertex (defaut: 0,0,0)
  47939. * @param normal the normal of the vertex (defaut: 0,1,0)
  47940. */
  47941. constructor(
  47942. /** the position of the vertex (defaut: 0,0,0) */
  47943. position?: Vector3,
  47944. /** the normal of the vertex (defaut: 0,1,0) */
  47945. normal?: Vector3);
  47946. /**
  47947. * Clones the PositionNormalVertex
  47948. * @returns the cloned PositionNormalVertex
  47949. */
  47950. clone(): PositionNormalVertex;
  47951. }
  47952. /**
  47953. * Contains position, normal and uv vectors for a vertex
  47954. */
  47955. export class PositionNormalTextureVertex {
  47956. /** the position of the vertex (defaut: 0,0,0) */
  47957. position: Vector3;
  47958. /** the normal of the vertex (defaut: 0,1,0) */
  47959. normal: Vector3;
  47960. /** the uv of the vertex (default: 0,0) */
  47961. uv: Vector2;
  47962. /**
  47963. * Creates a PositionNormalTextureVertex
  47964. * @param position the position of the vertex (defaut: 0,0,0)
  47965. * @param normal the normal of the vertex (defaut: 0,1,0)
  47966. * @param uv the uv of the vertex (default: 0,0)
  47967. */
  47968. constructor(
  47969. /** the position of the vertex (defaut: 0,0,0) */
  47970. position?: Vector3,
  47971. /** the normal of the vertex (defaut: 0,1,0) */
  47972. normal?: Vector3,
  47973. /** the uv of the vertex (default: 0,0) */
  47974. uv?: Vector2);
  47975. /**
  47976. * Clones the PositionNormalTextureVertex
  47977. * @returns the cloned PositionNormalTextureVertex
  47978. */
  47979. clone(): PositionNormalTextureVertex;
  47980. }
  47981. }
  47982. declare module BABYLON {
  47983. /** @hidden */
  47984. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47985. private _genericAttributeLocation;
  47986. private _varyingLocationCount;
  47987. private _varyingLocationMap;
  47988. private _replacements;
  47989. private _textureCount;
  47990. private _uniforms;
  47991. lineProcessor(line: string): string;
  47992. attributeProcessor(attribute: string): string;
  47993. varyingProcessor(varying: string, isFragment: boolean): string;
  47994. uniformProcessor(uniform: string): string;
  47995. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47996. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47997. }
  47998. }
  47999. declare module BABYLON {
  48000. /**
  48001. * Container for accessors for natively-stored mesh data buffers.
  48002. */
  48003. class NativeDataBuffer extends DataBuffer {
  48004. /**
  48005. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48006. */
  48007. nativeIndexBuffer?: any;
  48008. /**
  48009. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48010. */
  48011. nativeVertexBuffer?: any;
  48012. }
  48013. /** @hidden */
  48014. class NativeTexture extends InternalTexture {
  48015. getInternalTexture(): InternalTexture;
  48016. getViewCount(): number;
  48017. }
  48018. /** @hidden */
  48019. export class NativeEngine extends Engine {
  48020. private readonly _native;
  48021. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48022. private readonly INVALID_HANDLE;
  48023. getHardwareScalingLevel(): number;
  48024. constructor();
  48025. dispose(): void;
  48026. /**
  48027. * Can be used to override the current requestAnimationFrame requester.
  48028. * @hidden
  48029. */
  48030. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48031. /**
  48032. * Override default engine behavior.
  48033. * @param color
  48034. * @param backBuffer
  48035. * @param depth
  48036. * @param stencil
  48037. */
  48038. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48039. /**
  48040. * Gets host document
  48041. * @returns the host document object
  48042. */
  48043. getHostDocument(): Nullable<Document>;
  48044. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48045. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48046. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48047. recordVertexArrayObject(vertexBuffers: {
  48048. [key: string]: VertexBuffer;
  48049. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48050. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48051. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48052. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48053. /**
  48054. * Draw a list of indexed primitives
  48055. * @param fillMode defines the primitive to use
  48056. * @param indexStart defines the starting index
  48057. * @param indexCount defines the number of index to draw
  48058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48059. */
  48060. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48061. /**
  48062. * Draw a list of unindexed primitives
  48063. * @param fillMode defines the primitive to use
  48064. * @param verticesStart defines the index of first vertex to draw
  48065. * @param verticesCount defines the count of vertices to draw
  48066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48067. */
  48068. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48069. createPipelineContext(): IPipelineContext;
  48070. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48071. /** @hidden */
  48072. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48073. /** @hidden */
  48074. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48075. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48076. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48077. protected _setProgram(program: WebGLProgram): void;
  48078. _releaseEffect(effect: Effect): void;
  48079. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48080. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48081. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48082. bindSamplers(effect: Effect): void;
  48083. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48084. getRenderWidth(useScreen?: boolean): number;
  48085. getRenderHeight(useScreen?: boolean): number;
  48086. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48087. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48088. /**
  48089. * Set the z offset to apply to current rendering
  48090. * @param value defines the offset to apply
  48091. */
  48092. setZOffset(value: number): void;
  48093. /**
  48094. * Gets the current value of the zOffset
  48095. * @returns the current zOffset state
  48096. */
  48097. getZOffset(): number;
  48098. /**
  48099. * Enable or disable depth buffering
  48100. * @param enable defines the state to set
  48101. */
  48102. setDepthBuffer(enable: boolean): void;
  48103. /**
  48104. * Gets a boolean indicating if depth writing is enabled
  48105. * @returns the current depth writing state
  48106. */
  48107. getDepthWrite(): boolean;
  48108. /**
  48109. * Enable or disable depth writing
  48110. * @param enable defines the state to set
  48111. */
  48112. setDepthWrite(enable: boolean): void;
  48113. /**
  48114. * Enable or disable color writing
  48115. * @param enable defines the state to set
  48116. */
  48117. setColorWrite(enable: boolean): void;
  48118. /**
  48119. * Gets a boolean indicating if color writing is enabled
  48120. * @returns the current color writing state
  48121. */
  48122. getColorWrite(): boolean;
  48123. /**
  48124. * Sets alpha constants used by some alpha blending modes
  48125. * @param r defines the red component
  48126. * @param g defines the green component
  48127. * @param b defines the blue component
  48128. * @param a defines the alpha component
  48129. */
  48130. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48131. /**
  48132. * Sets the current alpha mode
  48133. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48134. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48135. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48136. */
  48137. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48138. /**
  48139. * Gets the current alpha mode
  48140. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48141. * @returns the current alpha mode
  48142. */
  48143. getAlphaMode(): number;
  48144. setInt(uniform: WebGLUniformLocation, int: number): void;
  48145. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48146. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48147. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48148. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48149. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48150. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48151. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48152. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48153. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48154. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48155. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48156. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48157. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48158. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48159. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48160. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48161. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48162. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48163. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48164. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48165. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48166. wipeCaches(bruteForce?: boolean): void;
  48167. _createTexture(): WebGLTexture;
  48168. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48169. /**
  48170. * Usually called from Texture.ts.
  48171. * Passed information to create a WebGLTexture
  48172. * @param url defines a value which contains one of the following:
  48173. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48174. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48175. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48176. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48177. * @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)
  48178. * @param scene needed for loading to the correct scene
  48179. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48180. * @param onLoad optional callback to be called upon successful completion
  48181. * @param onError optional callback to be called upon failure
  48182. * @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
  48183. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48184. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48185. * @param forcedExtension defines the extension to use to pick the right loader
  48186. * @param mimeType defines an optional mime type
  48187. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48188. */
  48189. 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;
  48190. /**
  48191. * Creates a cube texture
  48192. * @param rootUrl defines the url where the files to load is located
  48193. * @param scene defines the current scene
  48194. * @param files defines the list of files to load (1 per face)
  48195. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48196. * @param onLoad defines an optional callback raised when the texture is loaded
  48197. * @param onError defines an optional callback raised if there is an issue to load the texture
  48198. * @param format defines the format of the data
  48199. * @param forcedExtension defines the extension to use to pick the right loader
  48200. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48201. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48202. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48203. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48204. * @returns the cube texture as an InternalTexture
  48205. */
  48206. 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;
  48207. private _getSamplingFilter;
  48208. private static _GetNativeTextureFormat;
  48209. createRenderTargetTexture(size: number | {
  48210. width: number;
  48211. height: number;
  48212. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48213. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48214. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48215. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48216. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48217. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48218. /**
  48219. * Updates a dynamic vertex buffer.
  48220. * @param vertexBuffer the vertex buffer to update
  48221. * @param data the data used to update the vertex buffer
  48222. * @param byteOffset the byte offset of the data (optional)
  48223. * @param byteLength the byte length of the data (optional)
  48224. */
  48225. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48226. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48227. private _updateAnisotropicLevel;
  48228. private _getAddressMode;
  48229. /** @hidden */
  48230. _bindTexture(channel: number, texture: InternalTexture): void;
  48231. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48232. releaseEffects(): void;
  48233. /** @hidden */
  48234. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48235. /** @hidden */
  48236. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48237. /** @hidden */
  48238. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48239. /** @hidden */
  48240. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48241. }
  48242. }
  48243. declare module BABYLON {
  48244. /**
  48245. * Gather the list of clipboard event types as constants.
  48246. */
  48247. export class ClipboardEventTypes {
  48248. /**
  48249. * The clipboard event is fired when a copy command is active (pressed).
  48250. */
  48251. static readonly COPY: number;
  48252. /**
  48253. * The clipboard event is fired when a cut command is active (pressed).
  48254. */
  48255. static readonly CUT: number;
  48256. /**
  48257. * The clipboard event is fired when a paste command is active (pressed).
  48258. */
  48259. static readonly PASTE: number;
  48260. }
  48261. /**
  48262. * This class is used to store clipboard related info for the onClipboardObservable event.
  48263. */
  48264. export class ClipboardInfo {
  48265. /**
  48266. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48267. */
  48268. type: number;
  48269. /**
  48270. * Defines the related dom event
  48271. */
  48272. event: ClipboardEvent;
  48273. /**
  48274. *Creates an instance of ClipboardInfo.
  48275. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48276. * @param event Defines the related dom event
  48277. */
  48278. constructor(
  48279. /**
  48280. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48281. */
  48282. type: number,
  48283. /**
  48284. * Defines the related dom event
  48285. */
  48286. event: ClipboardEvent);
  48287. /**
  48288. * Get the clipboard event's type from the keycode.
  48289. * @param keyCode Defines the keyCode for the current keyboard event.
  48290. * @return {number}
  48291. */
  48292. static GetTypeFromCharacter(keyCode: number): number;
  48293. }
  48294. }
  48295. declare module BABYLON {
  48296. /**
  48297. * Google Daydream controller
  48298. */
  48299. export class DaydreamController extends WebVRController {
  48300. /**
  48301. * Base Url for the controller model.
  48302. */
  48303. static MODEL_BASE_URL: string;
  48304. /**
  48305. * File name for the controller model.
  48306. */
  48307. static MODEL_FILENAME: string;
  48308. /**
  48309. * Gamepad Id prefix used to identify Daydream Controller.
  48310. */
  48311. static readonly GAMEPAD_ID_PREFIX: string;
  48312. /**
  48313. * Creates a new DaydreamController from a gamepad
  48314. * @param vrGamepad the gamepad that the controller should be created from
  48315. */
  48316. constructor(vrGamepad: any);
  48317. /**
  48318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48319. * @param scene scene in which to add meshes
  48320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48321. */
  48322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48323. /**
  48324. * Called once for each button that changed state since the last frame
  48325. * @param buttonIdx Which button index changed
  48326. * @param state New state of the button
  48327. * @param changes Which properties on the state changed since last frame
  48328. */
  48329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48330. }
  48331. }
  48332. declare module BABYLON {
  48333. /**
  48334. * Gear VR Controller
  48335. */
  48336. export class GearVRController extends WebVRController {
  48337. /**
  48338. * Base Url for the controller model.
  48339. */
  48340. static MODEL_BASE_URL: string;
  48341. /**
  48342. * File name for the controller model.
  48343. */
  48344. static MODEL_FILENAME: string;
  48345. /**
  48346. * Gamepad Id prefix used to identify this controller.
  48347. */
  48348. static readonly GAMEPAD_ID_PREFIX: string;
  48349. private readonly _buttonIndexToObservableNameMap;
  48350. /**
  48351. * Creates a new GearVRController from a gamepad
  48352. * @param vrGamepad the gamepad that the controller should be created from
  48353. */
  48354. constructor(vrGamepad: any);
  48355. /**
  48356. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48357. * @param scene scene in which to add meshes
  48358. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48359. */
  48360. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48361. /**
  48362. * Called once for each button that changed state since the last frame
  48363. * @param buttonIdx Which button index changed
  48364. * @param state New state of the button
  48365. * @param changes Which properties on the state changed since last frame
  48366. */
  48367. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48368. }
  48369. }
  48370. declare module BABYLON {
  48371. /**
  48372. * Generic Controller
  48373. */
  48374. export class GenericController extends WebVRController {
  48375. /**
  48376. * Base Url for the controller model.
  48377. */
  48378. static readonly MODEL_BASE_URL: string;
  48379. /**
  48380. * File name for the controller model.
  48381. */
  48382. static readonly MODEL_FILENAME: string;
  48383. /**
  48384. * Creates a new GenericController from a gamepad
  48385. * @param vrGamepad the gamepad that the controller should be created from
  48386. */
  48387. constructor(vrGamepad: any);
  48388. /**
  48389. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48390. * @param scene scene in which to add meshes
  48391. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48392. */
  48393. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48394. /**
  48395. * Called once for each button that changed state since the last frame
  48396. * @param buttonIdx Which button index changed
  48397. * @param state New state of the button
  48398. * @param changes Which properties on the state changed since last frame
  48399. */
  48400. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48401. }
  48402. }
  48403. declare module BABYLON {
  48404. /**
  48405. * Oculus Touch Controller
  48406. */
  48407. export class OculusTouchController extends WebVRController {
  48408. /**
  48409. * Base Url for the controller model.
  48410. */
  48411. static MODEL_BASE_URL: string;
  48412. /**
  48413. * File name for the left controller model.
  48414. */
  48415. static MODEL_LEFT_FILENAME: string;
  48416. /**
  48417. * File name for the right controller model.
  48418. */
  48419. static MODEL_RIGHT_FILENAME: string;
  48420. /**
  48421. * Base Url for the Quest controller model.
  48422. */
  48423. static QUEST_MODEL_BASE_URL: string;
  48424. /**
  48425. * @hidden
  48426. * If the controllers are running on a device that needs the updated Quest controller models
  48427. */
  48428. static _IsQuest: boolean;
  48429. /**
  48430. * Fired when the secondary trigger on this controller is modified
  48431. */
  48432. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48433. /**
  48434. * Fired when the thumb rest on this controller is modified
  48435. */
  48436. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48437. /**
  48438. * Creates a new OculusTouchController from a gamepad
  48439. * @param vrGamepad the gamepad that the controller should be created from
  48440. */
  48441. constructor(vrGamepad: any);
  48442. /**
  48443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48444. * @param scene scene in which to add meshes
  48445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48446. */
  48447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48448. /**
  48449. * Fired when the A button on this controller is modified
  48450. */
  48451. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48452. /**
  48453. * Fired when the B button on this controller is modified
  48454. */
  48455. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48456. /**
  48457. * Fired when the X button on this controller is modified
  48458. */
  48459. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48460. /**
  48461. * Fired when the Y button on this controller is modified
  48462. */
  48463. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48464. /**
  48465. * Called once for each button that changed state since the last frame
  48466. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48467. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48468. * 2) secondary trigger (same)
  48469. * 3) A (right) X (left), touch, pressed = value
  48470. * 4) B / Y
  48471. * 5) thumb rest
  48472. * @param buttonIdx Which button index changed
  48473. * @param state New state of the button
  48474. * @param changes Which properties on the state changed since last frame
  48475. */
  48476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48477. }
  48478. }
  48479. declare module BABYLON {
  48480. /**
  48481. * Vive Controller
  48482. */
  48483. export class ViveController extends WebVRController {
  48484. /**
  48485. * Base Url for the controller model.
  48486. */
  48487. static MODEL_BASE_URL: string;
  48488. /**
  48489. * File name for the controller model.
  48490. */
  48491. static MODEL_FILENAME: string;
  48492. /**
  48493. * Creates a new ViveController from a gamepad
  48494. * @param vrGamepad the gamepad that the controller should be created from
  48495. */
  48496. constructor(vrGamepad: any);
  48497. /**
  48498. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48499. * @param scene scene in which to add meshes
  48500. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48501. */
  48502. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48503. /**
  48504. * Fired when the left button on this controller is modified
  48505. */
  48506. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48507. /**
  48508. * Fired when the right button on this controller is modified
  48509. */
  48510. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48511. /**
  48512. * Fired when the menu button on this controller is modified
  48513. */
  48514. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48515. /**
  48516. * Called once for each button that changed state since the last frame
  48517. * Vive mapping:
  48518. * 0: touchpad
  48519. * 1: trigger
  48520. * 2: left AND right buttons
  48521. * 3: menu button
  48522. * @param buttonIdx Which button index changed
  48523. * @param state New state of the button
  48524. * @param changes Which properties on the state changed since last frame
  48525. */
  48526. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48527. }
  48528. }
  48529. declare module BABYLON {
  48530. /**
  48531. * Defines the WindowsMotionController object that the state of the windows motion controller
  48532. */
  48533. export class WindowsMotionController extends WebVRController {
  48534. /**
  48535. * The base url used to load the left and right controller models
  48536. */
  48537. static MODEL_BASE_URL: string;
  48538. /**
  48539. * The name of the left controller model file
  48540. */
  48541. static MODEL_LEFT_FILENAME: string;
  48542. /**
  48543. * The name of the right controller model file
  48544. */
  48545. static MODEL_RIGHT_FILENAME: string;
  48546. /**
  48547. * The controller name prefix for this controller type
  48548. */
  48549. static readonly GAMEPAD_ID_PREFIX: string;
  48550. /**
  48551. * The controller id pattern for this controller type
  48552. */
  48553. private static readonly GAMEPAD_ID_PATTERN;
  48554. private _loadedMeshInfo;
  48555. protected readonly _mapping: {
  48556. buttons: string[];
  48557. buttonMeshNames: {
  48558. trigger: string;
  48559. menu: string;
  48560. grip: string;
  48561. thumbstick: string;
  48562. trackpad: string;
  48563. };
  48564. buttonObservableNames: {
  48565. trigger: string;
  48566. menu: string;
  48567. grip: string;
  48568. thumbstick: string;
  48569. trackpad: string;
  48570. };
  48571. axisMeshNames: string[];
  48572. pointingPoseMeshName: string;
  48573. };
  48574. /**
  48575. * Fired when the trackpad on this controller is clicked
  48576. */
  48577. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48578. /**
  48579. * Fired when the trackpad on this controller is modified
  48580. */
  48581. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48582. /**
  48583. * The current x and y values of this controller's trackpad
  48584. */
  48585. trackpad: StickValues;
  48586. /**
  48587. * Creates a new WindowsMotionController from a gamepad
  48588. * @param vrGamepad the gamepad that the controller should be created from
  48589. */
  48590. constructor(vrGamepad: any);
  48591. /**
  48592. * Fired when the trigger on this controller is modified
  48593. */
  48594. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48595. /**
  48596. * Fired when the menu button on this controller is modified
  48597. */
  48598. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48599. /**
  48600. * Fired when the grip button on this controller is modified
  48601. */
  48602. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48603. /**
  48604. * Fired when the thumbstick button on this controller is modified
  48605. */
  48606. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48607. /**
  48608. * Fired when the touchpad button on this controller is modified
  48609. */
  48610. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48611. /**
  48612. * Fired when the touchpad values on this controller are modified
  48613. */
  48614. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48615. protected _updateTrackpad(): void;
  48616. /**
  48617. * Called once per frame by the engine.
  48618. */
  48619. update(): void;
  48620. /**
  48621. * Called once for each button that changed state since the last frame
  48622. * @param buttonIdx Which button index changed
  48623. * @param state New state of the button
  48624. * @param changes Which properties on the state changed since last frame
  48625. */
  48626. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48627. /**
  48628. * Moves the buttons on the controller mesh based on their current state
  48629. * @param buttonName the name of the button to move
  48630. * @param buttonValue the value of the button which determines the buttons new position
  48631. */
  48632. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48633. /**
  48634. * Moves the axis on the controller mesh based on its current state
  48635. * @param axis the index of the axis
  48636. * @param axisValue the value of the axis which determines the meshes new position
  48637. * @hidden
  48638. */
  48639. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48640. /**
  48641. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48642. * @param scene scene in which to add meshes
  48643. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48644. */
  48645. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48646. /**
  48647. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48648. * can be transformed by button presses and axes values, based on this._mapping.
  48649. *
  48650. * @param scene scene in which the meshes exist
  48651. * @param meshes list of meshes that make up the controller model to process
  48652. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48653. */
  48654. private processModel;
  48655. private createMeshInfo;
  48656. /**
  48657. * Gets the ray of the controller in the direction the controller is pointing
  48658. * @param length the length the resulting ray should be
  48659. * @returns a ray in the direction the controller is pointing
  48660. */
  48661. getForwardRay(length?: number): Ray;
  48662. /**
  48663. * Disposes of the controller
  48664. */
  48665. dispose(): void;
  48666. }
  48667. /**
  48668. * This class represents a new windows motion controller in XR.
  48669. */
  48670. export class XRWindowsMotionController extends WindowsMotionController {
  48671. /**
  48672. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48673. */
  48674. protected readonly _mapping: {
  48675. buttons: string[];
  48676. buttonMeshNames: {
  48677. trigger: string;
  48678. menu: string;
  48679. grip: string;
  48680. thumbstick: string;
  48681. trackpad: string;
  48682. };
  48683. buttonObservableNames: {
  48684. trigger: string;
  48685. menu: string;
  48686. grip: string;
  48687. thumbstick: string;
  48688. trackpad: string;
  48689. };
  48690. axisMeshNames: string[];
  48691. pointingPoseMeshName: string;
  48692. };
  48693. /**
  48694. * Construct a new XR-Based windows motion controller
  48695. *
  48696. * @param gamepadInfo the gamepad object from the browser
  48697. */
  48698. constructor(gamepadInfo: any);
  48699. /**
  48700. * holds the thumbstick values (X,Y)
  48701. */
  48702. thumbstickValues: StickValues;
  48703. /**
  48704. * Fired when the thumbstick on this controller is clicked
  48705. */
  48706. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48707. /**
  48708. * Fired when the thumbstick on this controller is modified
  48709. */
  48710. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48711. /**
  48712. * Fired when the touchpad button on this controller is modified
  48713. */
  48714. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48715. /**
  48716. * Fired when the touchpad values on this controller are modified
  48717. */
  48718. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48719. /**
  48720. * Fired when the thumbstick button on this controller is modified
  48721. * here to prevent breaking changes
  48722. */
  48723. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48724. /**
  48725. * updating the thumbstick(!) and not the trackpad.
  48726. * This is named this way due to the difference between WebVR and XR and to avoid
  48727. * changing the parent class.
  48728. */
  48729. protected _updateTrackpad(): void;
  48730. /**
  48731. * Disposes the class with joy
  48732. */
  48733. dispose(): void;
  48734. }
  48735. }
  48736. declare module BABYLON {
  48737. /**
  48738. * Class containing static functions to help procedurally build meshes
  48739. */
  48740. export class PolyhedronBuilder {
  48741. /**
  48742. * Creates a polyhedron mesh
  48743. * * 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
  48744. * * The parameter `size` (positive float, default 1) sets the polygon size
  48745. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48746. * * 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`
  48747. * * 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
  48748. * * 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)`)
  48749. * * 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
  48750. * * 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
  48751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48752. * * 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
  48753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48754. * @param name defines the name of the mesh
  48755. * @param options defines the options used to create the mesh
  48756. * @param scene defines the hosting scene
  48757. * @returns the polyhedron mesh
  48758. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48759. */
  48760. static CreatePolyhedron(name: string, options: {
  48761. type?: number;
  48762. size?: number;
  48763. sizeX?: number;
  48764. sizeY?: number;
  48765. sizeZ?: number;
  48766. custom?: any;
  48767. faceUV?: Vector4[];
  48768. faceColors?: Color4[];
  48769. flat?: boolean;
  48770. updatable?: boolean;
  48771. sideOrientation?: number;
  48772. frontUVs?: Vector4;
  48773. backUVs?: Vector4;
  48774. }, scene?: Nullable<Scene>): Mesh;
  48775. }
  48776. }
  48777. declare module BABYLON {
  48778. /**
  48779. * Gizmo that enables scaling a mesh along 3 axis
  48780. */
  48781. export class ScaleGizmo extends Gizmo {
  48782. /**
  48783. * Internal gizmo used for interactions on the x axis
  48784. */
  48785. xGizmo: AxisScaleGizmo;
  48786. /**
  48787. * Internal gizmo used for interactions on the y axis
  48788. */
  48789. yGizmo: AxisScaleGizmo;
  48790. /**
  48791. * Internal gizmo used for interactions on the z axis
  48792. */
  48793. zGizmo: AxisScaleGizmo;
  48794. /**
  48795. * Internal gizmo used to scale all axis equally
  48796. */
  48797. uniformScaleGizmo: AxisScaleGizmo;
  48798. private _meshAttached;
  48799. private _updateGizmoRotationToMatchAttachedMesh;
  48800. private _snapDistance;
  48801. private _scaleRatio;
  48802. private _uniformScalingMesh;
  48803. private _octahedron;
  48804. private _sensitivity;
  48805. /** Fires an event when any of it's sub gizmos are dragged */
  48806. onDragStartObservable: Observable<unknown>;
  48807. /** Fires an event when any of it's sub gizmos are released from dragging */
  48808. onDragEndObservable: Observable<unknown>;
  48809. get attachedMesh(): Nullable<AbstractMesh>;
  48810. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48811. /**
  48812. * Creates a ScaleGizmo
  48813. * @param gizmoLayer The utility layer the gizmo will be added to
  48814. */
  48815. constructor(gizmoLayer?: UtilityLayerRenderer);
  48816. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48817. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48818. /**
  48819. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48820. */
  48821. set snapDistance(value: number);
  48822. get snapDistance(): number;
  48823. /**
  48824. * Ratio for the scale of the gizmo (Default: 1)
  48825. */
  48826. set scaleRatio(value: number);
  48827. get scaleRatio(): number;
  48828. /**
  48829. * Sensitivity factor for dragging (Default: 1)
  48830. */
  48831. set sensitivity(value: number);
  48832. get sensitivity(): number;
  48833. /**
  48834. * Disposes of the gizmo
  48835. */
  48836. dispose(): void;
  48837. }
  48838. }
  48839. declare module BABYLON {
  48840. /**
  48841. * Single axis scale gizmo
  48842. */
  48843. export class AxisScaleGizmo extends Gizmo {
  48844. /**
  48845. * Drag behavior responsible for the gizmos dragging interactions
  48846. */
  48847. dragBehavior: PointerDragBehavior;
  48848. private _pointerObserver;
  48849. /**
  48850. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48851. */
  48852. snapDistance: number;
  48853. /**
  48854. * Event that fires each time the gizmo snaps to a new location.
  48855. * * snapDistance is the the change in distance
  48856. */
  48857. onSnapObservable: Observable<{
  48858. snapDistance: number;
  48859. }>;
  48860. /**
  48861. * If the scaling operation should be done on all axis (default: false)
  48862. */
  48863. uniformScaling: boolean;
  48864. /**
  48865. * Custom sensitivity value for the drag strength
  48866. */
  48867. sensitivity: number;
  48868. private _isEnabled;
  48869. private _parent;
  48870. private _arrow;
  48871. private _coloredMaterial;
  48872. private _hoverMaterial;
  48873. /**
  48874. * Creates an AxisScaleGizmo
  48875. * @param gizmoLayer The utility layer the gizmo will be added to
  48876. * @param dragAxis The axis which the gizmo will be able to scale on
  48877. * @param color The color of the gizmo
  48878. */
  48879. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48880. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48881. /**
  48882. * If the gizmo is enabled
  48883. */
  48884. set isEnabled(value: boolean);
  48885. get isEnabled(): boolean;
  48886. /**
  48887. * Disposes of the gizmo
  48888. */
  48889. dispose(): void;
  48890. /**
  48891. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48892. * @param mesh The mesh to replace the default mesh of the gizmo
  48893. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48894. */
  48895. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48896. }
  48897. }
  48898. declare module BABYLON {
  48899. /**
  48900. * Bounding box gizmo
  48901. */
  48902. export class BoundingBoxGizmo extends Gizmo {
  48903. private _lineBoundingBox;
  48904. private _rotateSpheresParent;
  48905. private _scaleBoxesParent;
  48906. private _boundingDimensions;
  48907. private _renderObserver;
  48908. private _pointerObserver;
  48909. private _scaleDragSpeed;
  48910. private _tmpQuaternion;
  48911. private _tmpVector;
  48912. private _tmpRotationMatrix;
  48913. /**
  48914. * 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)
  48915. */
  48916. ignoreChildren: boolean;
  48917. /**
  48918. * 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)
  48919. */
  48920. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48921. /**
  48922. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48923. */
  48924. rotationSphereSize: number;
  48925. /**
  48926. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48927. */
  48928. scaleBoxSize: number;
  48929. /**
  48930. * 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)
  48931. */
  48932. fixedDragMeshScreenSize: boolean;
  48933. /**
  48934. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48935. */
  48936. fixedDragMeshScreenSizeDistanceFactor: number;
  48937. /**
  48938. * Fired when a rotation sphere or scale box is dragged
  48939. */
  48940. onDragStartObservable: Observable<{}>;
  48941. /**
  48942. * Fired when a scale box is dragged
  48943. */
  48944. onScaleBoxDragObservable: Observable<{}>;
  48945. /**
  48946. * Fired when a scale box drag is ended
  48947. */
  48948. onScaleBoxDragEndObservable: Observable<{}>;
  48949. /**
  48950. * Fired when a rotation sphere is dragged
  48951. */
  48952. onRotationSphereDragObservable: Observable<{}>;
  48953. /**
  48954. * Fired when a rotation sphere drag is ended
  48955. */
  48956. onRotationSphereDragEndObservable: Observable<{}>;
  48957. /**
  48958. * 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)
  48959. */
  48960. scalePivot: Nullable<Vector3>;
  48961. /**
  48962. * Mesh used as a pivot to rotate the attached mesh
  48963. */
  48964. private _anchorMesh;
  48965. private _existingMeshScale;
  48966. private _dragMesh;
  48967. private pointerDragBehavior;
  48968. private coloredMaterial;
  48969. private hoverColoredMaterial;
  48970. /**
  48971. * Sets the color of the bounding box gizmo
  48972. * @param color the color to set
  48973. */
  48974. setColor(color: Color3): void;
  48975. /**
  48976. * Creates an BoundingBoxGizmo
  48977. * @param gizmoLayer The utility layer the gizmo will be added to
  48978. * @param color The color of the gizmo
  48979. */
  48980. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48982. private _selectNode;
  48983. /**
  48984. * Updates the bounding box information for the Gizmo
  48985. */
  48986. updateBoundingBox(): void;
  48987. private _updateRotationSpheres;
  48988. private _updateScaleBoxes;
  48989. /**
  48990. * Enables rotation on the specified axis and disables rotation on the others
  48991. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48992. */
  48993. setEnabledRotationAxis(axis: string): void;
  48994. /**
  48995. * Enables/disables scaling
  48996. * @param enable if scaling should be enabled
  48997. * @param homogeneousScaling defines if scaling should only be homogeneous
  48998. */
  48999. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49000. private _updateDummy;
  49001. /**
  49002. * Enables a pointer drag behavior on the bounding box of the gizmo
  49003. */
  49004. enableDragBehavior(): void;
  49005. /**
  49006. * Disposes of the gizmo
  49007. */
  49008. dispose(): void;
  49009. /**
  49010. * 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)
  49011. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49012. * @returns the bounding box mesh with the passed in mesh as a child
  49013. */
  49014. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49015. /**
  49016. * CustomMeshes are not supported by this gizmo
  49017. * @param mesh The mesh to replace the default mesh of the gizmo
  49018. */
  49019. setCustomMesh(mesh: Mesh): void;
  49020. }
  49021. }
  49022. declare module BABYLON {
  49023. /**
  49024. * Single plane rotation gizmo
  49025. */
  49026. export class PlaneRotationGizmo extends Gizmo {
  49027. /**
  49028. * Drag behavior responsible for the gizmos dragging interactions
  49029. */
  49030. dragBehavior: PointerDragBehavior;
  49031. private _pointerObserver;
  49032. /**
  49033. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49034. */
  49035. snapDistance: number;
  49036. /**
  49037. * Event that fires each time the gizmo snaps to a new location.
  49038. * * snapDistance is the the change in distance
  49039. */
  49040. onSnapObservable: Observable<{
  49041. snapDistance: number;
  49042. }>;
  49043. private _isEnabled;
  49044. private _parent;
  49045. /**
  49046. * Creates a PlaneRotationGizmo
  49047. * @param gizmoLayer The utility layer the gizmo will be added to
  49048. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49049. * @param color The color of the gizmo
  49050. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49051. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49052. */
  49053. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49055. /**
  49056. * If the gizmo is enabled
  49057. */
  49058. set isEnabled(value: boolean);
  49059. get isEnabled(): boolean;
  49060. /**
  49061. * Disposes of the gizmo
  49062. */
  49063. dispose(): void;
  49064. }
  49065. }
  49066. declare module BABYLON {
  49067. /**
  49068. * Gizmo that enables rotating a mesh along 3 axis
  49069. */
  49070. export class RotationGizmo extends Gizmo {
  49071. /**
  49072. * Internal gizmo used for interactions on the x axis
  49073. */
  49074. xGizmo: PlaneRotationGizmo;
  49075. /**
  49076. * Internal gizmo used for interactions on the y axis
  49077. */
  49078. yGizmo: PlaneRotationGizmo;
  49079. /**
  49080. * Internal gizmo used for interactions on the z axis
  49081. */
  49082. zGizmo: PlaneRotationGizmo;
  49083. /** Fires an event when any of it's sub gizmos are dragged */
  49084. onDragStartObservable: Observable<unknown>;
  49085. /** Fires an event when any of it's sub gizmos are released from dragging */
  49086. onDragEndObservable: Observable<unknown>;
  49087. private _meshAttached;
  49088. get attachedMesh(): Nullable<AbstractMesh>;
  49089. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49090. /**
  49091. * Creates a RotationGizmo
  49092. * @param gizmoLayer The utility layer the gizmo will be added to
  49093. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49094. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49095. */
  49096. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49097. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49098. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49099. /**
  49100. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49101. */
  49102. set snapDistance(value: number);
  49103. get snapDistance(): number;
  49104. /**
  49105. * Ratio for the scale of the gizmo (Default: 1)
  49106. */
  49107. set scaleRatio(value: number);
  49108. get scaleRatio(): number;
  49109. /**
  49110. * Disposes of the gizmo
  49111. */
  49112. dispose(): void;
  49113. /**
  49114. * CustomMeshes are not supported by this gizmo
  49115. * @param mesh The mesh to replace the default mesh of the gizmo
  49116. */
  49117. setCustomMesh(mesh: Mesh): void;
  49118. }
  49119. }
  49120. declare module BABYLON {
  49121. /**
  49122. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49123. */
  49124. export class GizmoManager implements IDisposable {
  49125. private scene;
  49126. /**
  49127. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49128. */
  49129. gizmos: {
  49130. positionGizmo: Nullable<PositionGizmo>;
  49131. rotationGizmo: Nullable<RotationGizmo>;
  49132. scaleGizmo: Nullable<ScaleGizmo>;
  49133. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49134. };
  49135. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49136. clearGizmoOnEmptyPointerEvent: boolean;
  49137. /** Fires an event when the manager is attached to a mesh */
  49138. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49139. private _gizmosEnabled;
  49140. private _pointerObserver;
  49141. private _attachedMesh;
  49142. private _boundingBoxColor;
  49143. private _defaultUtilityLayer;
  49144. private _defaultKeepDepthUtilityLayer;
  49145. /**
  49146. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49147. */
  49148. boundingBoxDragBehavior: SixDofDragBehavior;
  49149. /**
  49150. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49151. */
  49152. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49153. /**
  49154. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49155. */
  49156. usePointerToAttachGizmos: boolean;
  49157. /**
  49158. * Utility layer that the bounding box gizmo belongs to
  49159. */
  49160. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49161. /**
  49162. * Utility layer that all gizmos besides bounding box belong to
  49163. */
  49164. get utilityLayer(): UtilityLayerRenderer;
  49165. /**
  49166. * Instatiates a gizmo manager
  49167. * @param scene the scene to overlay the gizmos on top of
  49168. */
  49169. constructor(scene: Scene);
  49170. /**
  49171. * Attaches a set of gizmos to the specified mesh
  49172. * @param mesh The mesh the gizmo's should be attached to
  49173. */
  49174. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49175. /**
  49176. * If the position gizmo is enabled
  49177. */
  49178. set positionGizmoEnabled(value: boolean);
  49179. get positionGizmoEnabled(): boolean;
  49180. /**
  49181. * If the rotation gizmo is enabled
  49182. */
  49183. set rotationGizmoEnabled(value: boolean);
  49184. get rotationGizmoEnabled(): boolean;
  49185. /**
  49186. * If the scale gizmo is enabled
  49187. */
  49188. set scaleGizmoEnabled(value: boolean);
  49189. get scaleGizmoEnabled(): boolean;
  49190. /**
  49191. * If the boundingBox gizmo is enabled
  49192. */
  49193. set boundingBoxGizmoEnabled(value: boolean);
  49194. get boundingBoxGizmoEnabled(): boolean;
  49195. /**
  49196. * Disposes of the gizmo manager
  49197. */
  49198. dispose(): void;
  49199. }
  49200. }
  49201. declare module BABYLON {
  49202. /**
  49203. * A directional light is defined by a direction (what a surprise!).
  49204. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49205. * 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.
  49206. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49207. */
  49208. export class DirectionalLight extends ShadowLight {
  49209. private _shadowFrustumSize;
  49210. /**
  49211. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49212. */
  49213. get shadowFrustumSize(): number;
  49214. /**
  49215. * Specifies a fix frustum size for the shadow generation.
  49216. */
  49217. set shadowFrustumSize(value: number);
  49218. private _shadowOrthoScale;
  49219. /**
  49220. * Gets the shadow projection scale against the optimal computed one.
  49221. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49222. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49223. */
  49224. get shadowOrthoScale(): number;
  49225. /**
  49226. * Sets the shadow projection scale against the optimal computed one.
  49227. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49228. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49229. */
  49230. set shadowOrthoScale(value: number);
  49231. /**
  49232. * Automatically compute the projection matrix to best fit (including all the casters)
  49233. * on each frame.
  49234. */
  49235. autoUpdateExtends: boolean;
  49236. /**
  49237. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49238. * on each frame. autoUpdateExtends must be set to true for this to work
  49239. */
  49240. autoCalcShadowZBounds: boolean;
  49241. private _orthoLeft;
  49242. private _orthoRight;
  49243. private _orthoTop;
  49244. private _orthoBottom;
  49245. /**
  49246. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49247. * The directional light is emitted from everywhere in the given direction.
  49248. * It can cast shadows.
  49249. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49250. * @param name The friendly name of the light
  49251. * @param direction The direction of the light
  49252. * @param scene The scene the light belongs to
  49253. */
  49254. constructor(name: string, direction: Vector3, scene: Scene);
  49255. /**
  49256. * Returns the string "DirectionalLight".
  49257. * @return The class name
  49258. */
  49259. getClassName(): string;
  49260. /**
  49261. * Returns the integer 1.
  49262. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49263. */
  49264. getTypeID(): number;
  49265. /**
  49266. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49267. * Returns the DirectionalLight Shadow projection matrix.
  49268. */
  49269. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49270. /**
  49271. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49272. * Returns the DirectionalLight Shadow projection matrix.
  49273. */
  49274. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49275. /**
  49276. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49277. * Returns the DirectionalLight Shadow projection matrix.
  49278. */
  49279. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49280. protected _buildUniformLayout(): void;
  49281. /**
  49282. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49283. * @param effect The effect to update
  49284. * @param lightIndex The index of the light in the effect to update
  49285. * @returns The directional light
  49286. */
  49287. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49288. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49289. /**
  49290. * Gets the minZ used for shadow according to both the scene and the light.
  49291. *
  49292. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49293. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49294. * @param activeCamera The camera we are returning the min for
  49295. * @returns the depth min z
  49296. */
  49297. getDepthMinZ(activeCamera: Camera): number;
  49298. /**
  49299. * Gets the maxZ used for shadow according to both the scene and the light.
  49300. *
  49301. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49302. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49303. * @param activeCamera The camera we are returning the max for
  49304. * @returns the depth max z
  49305. */
  49306. getDepthMaxZ(activeCamera: Camera): number;
  49307. /**
  49308. * Prepares the list of defines specific to the light type.
  49309. * @param defines the list of defines
  49310. * @param lightIndex defines the index of the light for the effect
  49311. */
  49312. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49313. }
  49314. }
  49315. declare module BABYLON {
  49316. /**
  49317. * Class containing static functions to help procedurally build meshes
  49318. */
  49319. export class HemisphereBuilder {
  49320. /**
  49321. * Creates a hemisphere mesh
  49322. * @param name defines the name of the mesh
  49323. * @param options defines the options used to create the mesh
  49324. * @param scene defines the hosting scene
  49325. * @returns the hemisphere mesh
  49326. */
  49327. static CreateHemisphere(name: string, options: {
  49328. segments?: number;
  49329. diameter?: number;
  49330. sideOrientation?: number;
  49331. }, scene: any): Mesh;
  49332. }
  49333. }
  49334. declare module BABYLON {
  49335. /**
  49336. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49337. * These values define a cone of light starting from the position, emitting toward the direction.
  49338. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49339. * and the exponent defines the speed of the decay of the light with distance (reach).
  49340. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49341. */
  49342. export class SpotLight extends ShadowLight {
  49343. private _angle;
  49344. private _innerAngle;
  49345. private _cosHalfAngle;
  49346. private _lightAngleScale;
  49347. private _lightAngleOffset;
  49348. /**
  49349. * Gets the cone angle of the spot light in Radians.
  49350. */
  49351. get angle(): number;
  49352. /**
  49353. * Sets the cone angle of the spot light in Radians.
  49354. */
  49355. set angle(value: number);
  49356. /**
  49357. * Only used in gltf falloff mode, this defines the angle where
  49358. * the directional falloff will start before cutting at angle which could be seen
  49359. * as outer angle.
  49360. */
  49361. get innerAngle(): number;
  49362. /**
  49363. * Only used in gltf falloff mode, this defines the angle where
  49364. * the directional falloff will start before cutting at angle which could be seen
  49365. * as outer angle.
  49366. */
  49367. set innerAngle(value: number);
  49368. private _shadowAngleScale;
  49369. /**
  49370. * Allows scaling the angle of the light for shadow generation only.
  49371. */
  49372. get shadowAngleScale(): number;
  49373. /**
  49374. * Allows scaling the angle of the light for shadow generation only.
  49375. */
  49376. set shadowAngleScale(value: number);
  49377. /**
  49378. * The light decay speed with the distance from the emission spot.
  49379. */
  49380. exponent: number;
  49381. private _projectionTextureMatrix;
  49382. /**
  49383. * Allows reading the projecton texture
  49384. */
  49385. get projectionTextureMatrix(): Matrix;
  49386. protected _projectionTextureLightNear: number;
  49387. /**
  49388. * Gets the near clip of the Spotlight for texture projection.
  49389. */
  49390. get projectionTextureLightNear(): number;
  49391. /**
  49392. * Sets the near clip of the Spotlight for texture projection.
  49393. */
  49394. set projectionTextureLightNear(value: number);
  49395. protected _projectionTextureLightFar: number;
  49396. /**
  49397. * Gets the far clip of the Spotlight for texture projection.
  49398. */
  49399. get projectionTextureLightFar(): number;
  49400. /**
  49401. * Sets the far clip of the Spotlight for texture projection.
  49402. */
  49403. set projectionTextureLightFar(value: number);
  49404. protected _projectionTextureUpDirection: Vector3;
  49405. /**
  49406. * Gets the Up vector of the Spotlight for texture projection.
  49407. */
  49408. get projectionTextureUpDirection(): Vector3;
  49409. /**
  49410. * Sets the Up vector of the Spotlight for texture projection.
  49411. */
  49412. set projectionTextureUpDirection(value: Vector3);
  49413. private _projectionTexture;
  49414. /**
  49415. * Gets the projection texture of the light.
  49416. */
  49417. get projectionTexture(): Nullable<BaseTexture>;
  49418. /**
  49419. * Sets the projection texture of the light.
  49420. */
  49421. set projectionTexture(value: Nullable<BaseTexture>);
  49422. private _projectionTextureViewLightDirty;
  49423. private _projectionTextureProjectionLightDirty;
  49424. private _projectionTextureDirty;
  49425. private _projectionTextureViewTargetVector;
  49426. private _projectionTextureViewLightMatrix;
  49427. private _projectionTextureProjectionLightMatrix;
  49428. private _projectionTextureScalingMatrix;
  49429. /**
  49430. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49431. * It can cast shadows.
  49432. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49433. * @param name The light friendly name
  49434. * @param position The position of the spot light in the scene
  49435. * @param direction The direction of the light in the scene
  49436. * @param angle The cone angle of the light in Radians
  49437. * @param exponent The light decay speed with the distance from the emission spot
  49438. * @param scene The scene the lights belongs to
  49439. */
  49440. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49441. /**
  49442. * Returns the string "SpotLight".
  49443. * @returns the class name
  49444. */
  49445. getClassName(): string;
  49446. /**
  49447. * Returns the integer 2.
  49448. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49449. */
  49450. getTypeID(): number;
  49451. /**
  49452. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49453. */
  49454. protected _setDirection(value: Vector3): void;
  49455. /**
  49456. * Overrides the position setter to recompute the projection texture view light Matrix.
  49457. */
  49458. protected _setPosition(value: Vector3): void;
  49459. /**
  49460. * 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.
  49461. * Returns the SpotLight.
  49462. */
  49463. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49464. protected _computeProjectionTextureViewLightMatrix(): void;
  49465. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49466. /**
  49467. * Main function for light texture projection matrix computing.
  49468. */
  49469. protected _computeProjectionTextureMatrix(): void;
  49470. protected _buildUniformLayout(): void;
  49471. private _computeAngleValues;
  49472. /**
  49473. * Sets the passed Effect "effect" with the Light textures.
  49474. * @param effect The effect to update
  49475. * @param lightIndex The index of the light in the effect to update
  49476. * @returns The light
  49477. */
  49478. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49479. /**
  49480. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49481. * @param effect The effect to update
  49482. * @param lightIndex The index of the light in the effect to update
  49483. * @returns The spot light
  49484. */
  49485. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49486. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49487. /**
  49488. * Disposes the light and the associated resources.
  49489. */
  49490. dispose(): void;
  49491. /**
  49492. * Prepares the list of defines specific to the light type.
  49493. * @param defines the list of defines
  49494. * @param lightIndex defines the index of the light for the effect
  49495. */
  49496. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49497. }
  49498. }
  49499. declare module BABYLON {
  49500. /**
  49501. * Gizmo that enables viewing a light
  49502. */
  49503. export class LightGizmo extends Gizmo {
  49504. private _lightMesh;
  49505. private _material;
  49506. private _cachedPosition;
  49507. private _cachedForward;
  49508. private _attachedMeshParent;
  49509. /**
  49510. * Creates a LightGizmo
  49511. * @param gizmoLayer The utility layer the gizmo will be added to
  49512. */
  49513. constructor(gizmoLayer?: UtilityLayerRenderer);
  49514. private _light;
  49515. /**
  49516. * The light that the gizmo is attached to
  49517. */
  49518. set light(light: Nullable<Light>);
  49519. get light(): Nullable<Light>;
  49520. /**
  49521. * Gets the material used to render the light gizmo
  49522. */
  49523. get material(): StandardMaterial;
  49524. /**
  49525. * @hidden
  49526. * Updates the gizmo to match the attached mesh's position/rotation
  49527. */
  49528. protected _update(): void;
  49529. private static _Scale;
  49530. /**
  49531. * Creates the lines for a light mesh
  49532. */
  49533. private static _CreateLightLines;
  49534. /**
  49535. * Disposes of the light gizmo
  49536. */
  49537. dispose(): void;
  49538. private static _CreateHemisphericLightMesh;
  49539. private static _CreatePointLightMesh;
  49540. private static _CreateSpotLightMesh;
  49541. private static _CreateDirectionalLightMesh;
  49542. }
  49543. }
  49544. declare module BABYLON {
  49545. /** @hidden */
  49546. export var backgroundFragmentDeclaration: {
  49547. name: string;
  49548. shader: string;
  49549. };
  49550. }
  49551. declare module BABYLON {
  49552. /** @hidden */
  49553. export var backgroundUboDeclaration: {
  49554. name: string;
  49555. shader: string;
  49556. };
  49557. }
  49558. declare module BABYLON {
  49559. /** @hidden */
  49560. export var backgroundPixelShader: {
  49561. name: string;
  49562. shader: string;
  49563. };
  49564. }
  49565. declare module BABYLON {
  49566. /** @hidden */
  49567. export var backgroundVertexDeclaration: {
  49568. name: string;
  49569. shader: string;
  49570. };
  49571. }
  49572. declare module BABYLON {
  49573. /** @hidden */
  49574. export var backgroundVertexShader: {
  49575. name: string;
  49576. shader: string;
  49577. };
  49578. }
  49579. declare module BABYLON {
  49580. /**
  49581. * Background material used to create an efficient environement around your scene.
  49582. */
  49583. export class BackgroundMaterial extends PushMaterial {
  49584. /**
  49585. * Standard reflectance value at parallel view angle.
  49586. */
  49587. static StandardReflectance0: number;
  49588. /**
  49589. * Standard reflectance value at grazing angle.
  49590. */
  49591. static StandardReflectance90: number;
  49592. protected _primaryColor: Color3;
  49593. /**
  49594. * Key light Color (multiply against the environement texture)
  49595. */
  49596. primaryColor: Color3;
  49597. protected __perceptualColor: Nullable<Color3>;
  49598. /**
  49599. * Experimental Internal Use Only.
  49600. *
  49601. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49602. * This acts as a helper to set the primary color to a more "human friendly" value.
  49603. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49604. * output color as close as possible from the chosen value.
  49605. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49606. * part of lighting setup.)
  49607. */
  49608. get _perceptualColor(): Nullable<Color3>;
  49609. set _perceptualColor(value: Nullable<Color3>);
  49610. protected _primaryColorShadowLevel: float;
  49611. /**
  49612. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49613. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49614. */
  49615. get primaryColorShadowLevel(): float;
  49616. set primaryColorShadowLevel(value: float);
  49617. protected _primaryColorHighlightLevel: float;
  49618. /**
  49619. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49620. * The primary color is used at the level chosen to define what the white area would look.
  49621. */
  49622. get primaryColorHighlightLevel(): float;
  49623. set primaryColorHighlightLevel(value: float);
  49624. protected _reflectionTexture: Nullable<BaseTexture>;
  49625. /**
  49626. * Reflection Texture used in the material.
  49627. * Should be author in a specific way for the best result (refer to the documentation).
  49628. */
  49629. reflectionTexture: Nullable<BaseTexture>;
  49630. protected _reflectionBlur: float;
  49631. /**
  49632. * Reflection Texture level of blur.
  49633. *
  49634. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49635. * texture twice.
  49636. */
  49637. reflectionBlur: float;
  49638. protected _diffuseTexture: Nullable<BaseTexture>;
  49639. /**
  49640. * Diffuse Texture used in the material.
  49641. * Should be author in a specific way for the best result (refer to the documentation).
  49642. */
  49643. diffuseTexture: Nullable<BaseTexture>;
  49644. protected _shadowLights: Nullable<IShadowLight[]>;
  49645. /**
  49646. * Specify the list of lights casting shadow on the material.
  49647. * All scene shadow lights will be included if null.
  49648. */
  49649. shadowLights: Nullable<IShadowLight[]>;
  49650. protected _shadowLevel: float;
  49651. /**
  49652. * Helps adjusting the shadow to a softer level if required.
  49653. * 0 means black shadows and 1 means no shadows.
  49654. */
  49655. shadowLevel: float;
  49656. protected _sceneCenter: Vector3;
  49657. /**
  49658. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49659. * It is usually zero but might be interesting to modify according to your setup.
  49660. */
  49661. sceneCenter: Vector3;
  49662. protected _opacityFresnel: boolean;
  49663. /**
  49664. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49665. * This helps ensuring a nice transition when the camera goes under the ground.
  49666. */
  49667. opacityFresnel: boolean;
  49668. protected _reflectionFresnel: boolean;
  49669. /**
  49670. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49671. * This helps adding a mirror texture on the ground.
  49672. */
  49673. reflectionFresnel: boolean;
  49674. protected _reflectionFalloffDistance: number;
  49675. /**
  49676. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49677. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49678. */
  49679. reflectionFalloffDistance: number;
  49680. protected _reflectionAmount: number;
  49681. /**
  49682. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49683. */
  49684. reflectionAmount: number;
  49685. protected _reflectionReflectance0: number;
  49686. /**
  49687. * This specifies the weight of the reflection at grazing angle.
  49688. */
  49689. reflectionReflectance0: number;
  49690. protected _reflectionReflectance90: number;
  49691. /**
  49692. * This specifies the weight of the reflection at a perpendicular point of view.
  49693. */
  49694. reflectionReflectance90: number;
  49695. /**
  49696. * Sets the reflection reflectance fresnel values according to the default standard
  49697. * empirically know to work well :-)
  49698. */
  49699. set reflectionStandardFresnelWeight(value: number);
  49700. protected _useRGBColor: boolean;
  49701. /**
  49702. * Helps to directly use the maps channels instead of their level.
  49703. */
  49704. useRGBColor: boolean;
  49705. protected _enableNoise: boolean;
  49706. /**
  49707. * This helps reducing the banding effect that could occur on the background.
  49708. */
  49709. enableNoise: boolean;
  49710. /**
  49711. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49712. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49713. * Recommended to be keep at 1.0 except for special cases.
  49714. */
  49715. get fovMultiplier(): number;
  49716. set fovMultiplier(value: number);
  49717. private _fovMultiplier;
  49718. /**
  49719. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49720. */
  49721. useEquirectangularFOV: boolean;
  49722. private _maxSimultaneousLights;
  49723. /**
  49724. * Number of Simultaneous lights allowed on the material.
  49725. */
  49726. maxSimultaneousLights: int;
  49727. /**
  49728. * Default configuration related to image processing available in the Background Material.
  49729. */
  49730. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49731. /**
  49732. * Keep track of the image processing observer to allow dispose and replace.
  49733. */
  49734. private _imageProcessingObserver;
  49735. /**
  49736. * Attaches a new image processing configuration to the PBR Material.
  49737. * @param configuration (if null the scene configuration will be use)
  49738. */
  49739. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49740. /**
  49741. * Gets the image processing configuration used either in this material.
  49742. */
  49743. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49744. /**
  49745. * Sets the Default image processing configuration used either in the this material.
  49746. *
  49747. * If sets to null, the scene one is in use.
  49748. */
  49749. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49750. /**
  49751. * Gets wether the color curves effect is enabled.
  49752. */
  49753. get cameraColorCurvesEnabled(): boolean;
  49754. /**
  49755. * Sets wether the color curves effect is enabled.
  49756. */
  49757. set cameraColorCurvesEnabled(value: boolean);
  49758. /**
  49759. * Gets wether the color grading effect is enabled.
  49760. */
  49761. get cameraColorGradingEnabled(): boolean;
  49762. /**
  49763. * Gets wether the color grading effect is enabled.
  49764. */
  49765. set cameraColorGradingEnabled(value: boolean);
  49766. /**
  49767. * Gets wether tonemapping is enabled or not.
  49768. */
  49769. get cameraToneMappingEnabled(): boolean;
  49770. /**
  49771. * Sets wether tonemapping is enabled or not
  49772. */
  49773. set cameraToneMappingEnabled(value: boolean);
  49774. /**
  49775. * The camera exposure used on this material.
  49776. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49777. * This corresponds to a photographic exposure.
  49778. */
  49779. get cameraExposure(): float;
  49780. /**
  49781. * The camera exposure used on this material.
  49782. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49783. * This corresponds to a photographic exposure.
  49784. */
  49785. set cameraExposure(value: float);
  49786. /**
  49787. * Gets The camera contrast used on this material.
  49788. */
  49789. get cameraContrast(): float;
  49790. /**
  49791. * Sets The camera contrast used on this material.
  49792. */
  49793. set cameraContrast(value: float);
  49794. /**
  49795. * Gets the Color Grading 2D Lookup Texture.
  49796. */
  49797. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49798. /**
  49799. * Sets the Color Grading 2D Lookup Texture.
  49800. */
  49801. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49802. /**
  49803. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49804. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49805. * 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;
  49806. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49807. */
  49808. get cameraColorCurves(): Nullable<ColorCurves>;
  49809. /**
  49810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49812. * 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;
  49813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49814. */
  49815. set cameraColorCurves(value: Nullable<ColorCurves>);
  49816. /**
  49817. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49818. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49819. */
  49820. switchToBGR: boolean;
  49821. private _renderTargets;
  49822. private _reflectionControls;
  49823. private _white;
  49824. private _primaryShadowColor;
  49825. private _primaryHighlightColor;
  49826. /**
  49827. * Instantiates a Background Material in the given scene
  49828. * @param name The friendly name of the material
  49829. * @param scene The scene to add the material to
  49830. */
  49831. constructor(name: string, scene: Scene);
  49832. /**
  49833. * Gets a boolean indicating that current material needs to register RTT
  49834. */
  49835. get hasRenderTargetTextures(): boolean;
  49836. /**
  49837. * The entire material has been created in order to prevent overdraw.
  49838. * @returns false
  49839. */
  49840. needAlphaTesting(): boolean;
  49841. /**
  49842. * The entire material has been created in order to prevent overdraw.
  49843. * @returns true if blending is enable
  49844. */
  49845. needAlphaBlending(): boolean;
  49846. /**
  49847. * Checks wether the material is ready to be rendered for a given mesh.
  49848. * @param mesh The mesh to render
  49849. * @param subMesh The submesh to check against
  49850. * @param useInstances Specify wether or not the material is used with instances
  49851. * @returns true if all the dependencies are ready (Textures, Effects...)
  49852. */
  49853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49854. /**
  49855. * Compute the primary color according to the chosen perceptual color.
  49856. */
  49857. private _computePrimaryColorFromPerceptualColor;
  49858. /**
  49859. * Compute the highlights and shadow colors according to their chosen levels.
  49860. */
  49861. private _computePrimaryColors;
  49862. /**
  49863. * Build the uniform buffer used in the material.
  49864. */
  49865. buildUniformLayout(): void;
  49866. /**
  49867. * Unbind the material.
  49868. */
  49869. unbind(): void;
  49870. /**
  49871. * Bind only the world matrix to the material.
  49872. * @param world The world matrix to bind.
  49873. */
  49874. bindOnlyWorldMatrix(world: Matrix): void;
  49875. /**
  49876. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49877. * @param world The world matrix to bind.
  49878. * @param subMesh The submesh to bind for.
  49879. */
  49880. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49881. /**
  49882. * Checks to see if a texture is used in the material.
  49883. * @param texture - Base texture to use.
  49884. * @returns - Boolean specifying if a texture is used in the material.
  49885. */
  49886. hasTexture(texture: BaseTexture): boolean;
  49887. /**
  49888. * Dispose the material.
  49889. * @param forceDisposeEffect Force disposal of the associated effect.
  49890. * @param forceDisposeTextures Force disposal of the associated textures.
  49891. */
  49892. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49893. /**
  49894. * Clones the material.
  49895. * @param name The cloned name.
  49896. * @returns The cloned material.
  49897. */
  49898. clone(name: string): BackgroundMaterial;
  49899. /**
  49900. * Serializes the current material to its JSON representation.
  49901. * @returns The JSON representation.
  49902. */
  49903. serialize(): any;
  49904. /**
  49905. * Gets the class name of the material
  49906. * @returns "BackgroundMaterial"
  49907. */
  49908. getClassName(): string;
  49909. /**
  49910. * Parse a JSON input to create back a background material.
  49911. * @param source The JSON data to parse
  49912. * @param scene The scene to create the parsed material in
  49913. * @param rootUrl The root url of the assets the material depends upon
  49914. * @returns the instantiated BackgroundMaterial.
  49915. */
  49916. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /**
  49921. * Represents the different options available during the creation of
  49922. * a Environment helper.
  49923. *
  49924. * This can control the default ground, skybox and image processing setup of your scene.
  49925. */
  49926. export interface IEnvironmentHelperOptions {
  49927. /**
  49928. * Specifies whether or not to create a ground.
  49929. * True by default.
  49930. */
  49931. createGround: boolean;
  49932. /**
  49933. * Specifies the ground size.
  49934. * 15 by default.
  49935. */
  49936. groundSize: number;
  49937. /**
  49938. * The texture used on the ground for the main color.
  49939. * Comes from the BabylonJS CDN by default.
  49940. *
  49941. * Remarks: Can be either a texture or a url.
  49942. */
  49943. groundTexture: string | BaseTexture;
  49944. /**
  49945. * The color mixed in the ground texture by default.
  49946. * BabylonJS clearColor by default.
  49947. */
  49948. groundColor: Color3;
  49949. /**
  49950. * Specifies the ground opacity.
  49951. * 1 by default.
  49952. */
  49953. groundOpacity: number;
  49954. /**
  49955. * Enables the ground to receive shadows.
  49956. * True by default.
  49957. */
  49958. enableGroundShadow: boolean;
  49959. /**
  49960. * Helps preventing the shadow to be fully black on the ground.
  49961. * 0.5 by default.
  49962. */
  49963. groundShadowLevel: number;
  49964. /**
  49965. * Creates a mirror texture attach to the ground.
  49966. * false by default.
  49967. */
  49968. enableGroundMirror: boolean;
  49969. /**
  49970. * Specifies the ground mirror size ratio.
  49971. * 0.3 by default as the default kernel is 64.
  49972. */
  49973. groundMirrorSizeRatio: number;
  49974. /**
  49975. * Specifies the ground mirror blur kernel size.
  49976. * 64 by default.
  49977. */
  49978. groundMirrorBlurKernel: number;
  49979. /**
  49980. * Specifies the ground mirror visibility amount.
  49981. * 1 by default
  49982. */
  49983. groundMirrorAmount: number;
  49984. /**
  49985. * Specifies the ground mirror reflectance weight.
  49986. * This uses the standard weight of the background material to setup the fresnel effect
  49987. * of the mirror.
  49988. * 1 by default.
  49989. */
  49990. groundMirrorFresnelWeight: number;
  49991. /**
  49992. * Specifies the ground mirror Falloff distance.
  49993. * This can helps reducing the size of the reflection.
  49994. * 0 by Default.
  49995. */
  49996. groundMirrorFallOffDistance: number;
  49997. /**
  49998. * Specifies the ground mirror texture type.
  49999. * Unsigned Int by Default.
  50000. */
  50001. groundMirrorTextureType: number;
  50002. /**
  50003. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50004. * the shown objects.
  50005. */
  50006. groundYBias: number;
  50007. /**
  50008. * Specifies whether or not to create a skybox.
  50009. * True by default.
  50010. */
  50011. createSkybox: boolean;
  50012. /**
  50013. * Specifies the skybox size.
  50014. * 20 by default.
  50015. */
  50016. skyboxSize: number;
  50017. /**
  50018. * The texture used on the skybox for the main color.
  50019. * Comes from the BabylonJS CDN by default.
  50020. *
  50021. * Remarks: Can be either a texture or a url.
  50022. */
  50023. skyboxTexture: string | BaseTexture;
  50024. /**
  50025. * The color mixed in the skybox texture by default.
  50026. * BabylonJS clearColor by default.
  50027. */
  50028. skyboxColor: Color3;
  50029. /**
  50030. * The background rotation around the Y axis of the scene.
  50031. * This helps aligning the key lights of your scene with the background.
  50032. * 0 by default.
  50033. */
  50034. backgroundYRotation: number;
  50035. /**
  50036. * Compute automatically the size of the elements to best fit with the scene.
  50037. */
  50038. sizeAuto: boolean;
  50039. /**
  50040. * Default position of the rootMesh if autoSize is not true.
  50041. */
  50042. rootPosition: Vector3;
  50043. /**
  50044. * Sets up the image processing in the scene.
  50045. * true by default.
  50046. */
  50047. setupImageProcessing: boolean;
  50048. /**
  50049. * The texture used as your environment texture in the scene.
  50050. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50051. *
  50052. * Remarks: Can be either a texture or a url.
  50053. */
  50054. environmentTexture: string | BaseTexture;
  50055. /**
  50056. * The value of the exposure to apply to the scene.
  50057. * 0.6 by default if setupImageProcessing is true.
  50058. */
  50059. cameraExposure: number;
  50060. /**
  50061. * The value of the contrast to apply to the scene.
  50062. * 1.6 by default if setupImageProcessing is true.
  50063. */
  50064. cameraContrast: number;
  50065. /**
  50066. * Specifies whether or not tonemapping should be enabled in the scene.
  50067. * true by default if setupImageProcessing is true.
  50068. */
  50069. toneMappingEnabled: boolean;
  50070. }
  50071. /**
  50072. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50073. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50074. * It also helps with the default setup of your imageProcessing configuration.
  50075. */
  50076. export class EnvironmentHelper {
  50077. /**
  50078. * Default ground texture URL.
  50079. */
  50080. private static _groundTextureCDNUrl;
  50081. /**
  50082. * Default skybox texture URL.
  50083. */
  50084. private static _skyboxTextureCDNUrl;
  50085. /**
  50086. * Default environment texture URL.
  50087. */
  50088. private static _environmentTextureCDNUrl;
  50089. /**
  50090. * Creates the default options for the helper.
  50091. */
  50092. private static _getDefaultOptions;
  50093. private _rootMesh;
  50094. /**
  50095. * Gets the root mesh created by the helper.
  50096. */
  50097. get rootMesh(): Mesh;
  50098. private _skybox;
  50099. /**
  50100. * Gets the skybox created by the helper.
  50101. */
  50102. get skybox(): Nullable<Mesh>;
  50103. private _skyboxTexture;
  50104. /**
  50105. * Gets the skybox texture created by the helper.
  50106. */
  50107. get skyboxTexture(): Nullable<BaseTexture>;
  50108. private _skyboxMaterial;
  50109. /**
  50110. * Gets the skybox material created by the helper.
  50111. */
  50112. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50113. private _ground;
  50114. /**
  50115. * Gets the ground mesh created by the helper.
  50116. */
  50117. get ground(): Nullable<Mesh>;
  50118. private _groundTexture;
  50119. /**
  50120. * Gets the ground texture created by the helper.
  50121. */
  50122. get groundTexture(): Nullable<BaseTexture>;
  50123. private _groundMirror;
  50124. /**
  50125. * Gets the ground mirror created by the helper.
  50126. */
  50127. get groundMirror(): Nullable<MirrorTexture>;
  50128. /**
  50129. * Gets the ground mirror render list to helps pushing the meshes
  50130. * you wish in the ground reflection.
  50131. */
  50132. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50133. private _groundMaterial;
  50134. /**
  50135. * Gets the ground material created by the helper.
  50136. */
  50137. get groundMaterial(): Nullable<BackgroundMaterial>;
  50138. /**
  50139. * Stores the creation options.
  50140. */
  50141. private readonly _scene;
  50142. private _options;
  50143. /**
  50144. * This observable will be notified with any error during the creation of the environment,
  50145. * mainly texture creation errors.
  50146. */
  50147. onErrorObservable: Observable<{
  50148. message?: string;
  50149. exception?: any;
  50150. }>;
  50151. /**
  50152. * constructor
  50153. * @param options Defines the options we want to customize the helper
  50154. * @param scene The scene to add the material to
  50155. */
  50156. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50157. /**
  50158. * Updates the background according to the new options
  50159. * @param options
  50160. */
  50161. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50162. /**
  50163. * Sets the primary color of all the available elements.
  50164. * @param color the main color to affect to the ground and the background
  50165. */
  50166. setMainColor(color: Color3): void;
  50167. /**
  50168. * Setup the image processing according to the specified options.
  50169. */
  50170. private _setupImageProcessing;
  50171. /**
  50172. * Setup the environment texture according to the specified options.
  50173. */
  50174. private _setupEnvironmentTexture;
  50175. /**
  50176. * Setup the background according to the specified options.
  50177. */
  50178. private _setupBackground;
  50179. /**
  50180. * Get the scene sizes according to the setup.
  50181. */
  50182. private _getSceneSize;
  50183. /**
  50184. * Setup the ground according to the specified options.
  50185. */
  50186. private _setupGround;
  50187. /**
  50188. * Setup the ground material according to the specified options.
  50189. */
  50190. private _setupGroundMaterial;
  50191. /**
  50192. * Setup the ground diffuse texture according to the specified options.
  50193. */
  50194. private _setupGroundDiffuseTexture;
  50195. /**
  50196. * Setup the ground mirror texture according to the specified options.
  50197. */
  50198. private _setupGroundMirrorTexture;
  50199. /**
  50200. * Setup the ground to receive the mirror texture.
  50201. */
  50202. private _setupMirrorInGroundMaterial;
  50203. /**
  50204. * Setup the skybox according to the specified options.
  50205. */
  50206. private _setupSkybox;
  50207. /**
  50208. * Setup the skybox material according to the specified options.
  50209. */
  50210. private _setupSkyboxMaterial;
  50211. /**
  50212. * Setup the skybox reflection texture according to the specified options.
  50213. */
  50214. private _setupSkyboxReflectionTexture;
  50215. private _errorHandler;
  50216. /**
  50217. * Dispose all the elements created by the Helper.
  50218. */
  50219. dispose(): void;
  50220. }
  50221. }
  50222. declare module BABYLON {
  50223. /**
  50224. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50225. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50226. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50227. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50228. */
  50229. export class PhotoDome extends TransformNode {
  50230. /**
  50231. * Define the image as a Monoscopic panoramic 360 image.
  50232. */
  50233. static readonly MODE_MONOSCOPIC: number;
  50234. /**
  50235. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50236. */
  50237. static readonly MODE_TOPBOTTOM: number;
  50238. /**
  50239. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50240. */
  50241. static readonly MODE_SIDEBYSIDE: number;
  50242. private _useDirectMapping;
  50243. /**
  50244. * The texture being displayed on the sphere
  50245. */
  50246. protected _photoTexture: Texture;
  50247. /**
  50248. * Gets or sets the texture being displayed on the sphere
  50249. */
  50250. get photoTexture(): Texture;
  50251. set photoTexture(value: Texture);
  50252. /**
  50253. * Observable raised when an error occured while loading the 360 image
  50254. */
  50255. onLoadErrorObservable: Observable<string>;
  50256. /**
  50257. * The skybox material
  50258. */
  50259. protected _material: BackgroundMaterial;
  50260. /**
  50261. * The surface used for the skybox
  50262. */
  50263. protected _mesh: Mesh;
  50264. /**
  50265. * Gets the mesh used for the skybox.
  50266. */
  50267. get mesh(): Mesh;
  50268. /**
  50269. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50270. * Also see the options.resolution property.
  50271. */
  50272. get fovMultiplier(): number;
  50273. set fovMultiplier(value: number);
  50274. private _imageMode;
  50275. /**
  50276. * Gets or set the current video mode for the video. It can be:
  50277. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50278. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50279. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50280. */
  50281. get imageMode(): number;
  50282. set imageMode(value: number);
  50283. /**
  50284. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50285. * @param name Element's name, child elements will append suffixes for their own names.
  50286. * @param urlsOfPhoto defines the url of the photo to display
  50287. * @param options defines an object containing optional or exposed sub element properties
  50288. * @param onError defines a callback called when an error occured while loading the texture
  50289. */
  50290. constructor(name: string, urlOfPhoto: string, options: {
  50291. resolution?: number;
  50292. size?: number;
  50293. useDirectMapping?: boolean;
  50294. faceForward?: boolean;
  50295. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50296. private _onBeforeCameraRenderObserver;
  50297. private _changeImageMode;
  50298. /**
  50299. * Releases resources associated with this node.
  50300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50302. */
  50303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50304. }
  50305. }
  50306. declare module BABYLON {
  50307. /**
  50308. * Class used to host RGBD texture specific utilities
  50309. */
  50310. export class RGBDTextureTools {
  50311. /**
  50312. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50313. * @param texture the texture to expand.
  50314. */
  50315. static ExpandRGBDTexture(texture: Texture): void;
  50316. }
  50317. }
  50318. declare module BABYLON {
  50319. /**
  50320. * Class used to host texture specific utilities
  50321. */
  50322. export class BRDFTextureTools {
  50323. /**
  50324. * Prevents texture cache collision
  50325. */
  50326. private static _instanceNumber;
  50327. /**
  50328. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50329. * @param scene defines the hosting scene
  50330. * @returns the environment BRDF texture
  50331. */
  50332. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50333. private static _environmentBRDFBase64Texture;
  50334. }
  50335. }
  50336. declare module BABYLON {
  50337. /**
  50338. * @hidden
  50339. */
  50340. export interface IMaterialClearCoatDefines {
  50341. CLEARCOAT: boolean;
  50342. CLEARCOAT_DEFAULTIOR: boolean;
  50343. CLEARCOAT_TEXTURE: boolean;
  50344. CLEARCOAT_TEXTUREDIRECTUV: number;
  50345. CLEARCOAT_BUMP: boolean;
  50346. CLEARCOAT_BUMPDIRECTUV: number;
  50347. CLEARCOAT_TINT: boolean;
  50348. CLEARCOAT_TINT_TEXTURE: boolean;
  50349. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50350. /** @hidden */
  50351. _areTexturesDirty: boolean;
  50352. }
  50353. /**
  50354. * Define the code related to the clear coat parameters of the pbr material.
  50355. */
  50356. export class PBRClearCoatConfiguration {
  50357. /**
  50358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50359. * The default fits with a polyurethane material.
  50360. */
  50361. private static readonly _DefaultIndexOfRefraction;
  50362. private _isEnabled;
  50363. /**
  50364. * Defines if the clear coat is enabled in the material.
  50365. */
  50366. isEnabled: boolean;
  50367. /**
  50368. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50369. */
  50370. intensity: number;
  50371. /**
  50372. * Defines the clear coat layer roughness.
  50373. */
  50374. roughness: number;
  50375. private _indexOfRefraction;
  50376. /**
  50377. * Defines the index of refraction of the clear coat.
  50378. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50379. * The default fits with a polyurethane material.
  50380. * Changing the default value is more performance intensive.
  50381. */
  50382. indexOfRefraction: number;
  50383. private _texture;
  50384. /**
  50385. * Stores the clear coat values in a texture.
  50386. */
  50387. texture: Nullable<BaseTexture>;
  50388. private _bumpTexture;
  50389. /**
  50390. * Define the clear coat specific bump texture.
  50391. */
  50392. bumpTexture: Nullable<BaseTexture>;
  50393. private _isTintEnabled;
  50394. /**
  50395. * Defines if the clear coat tint is enabled in the material.
  50396. */
  50397. isTintEnabled: boolean;
  50398. /**
  50399. * Defines the clear coat tint of the material.
  50400. * This is only use if tint is enabled
  50401. */
  50402. tintColor: Color3;
  50403. /**
  50404. * Defines the distance at which the tint color should be found in the
  50405. * clear coat media.
  50406. * This is only use if tint is enabled
  50407. */
  50408. tintColorAtDistance: number;
  50409. /**
  50410. * Defines the clear coat layer thickness.
  50411. * This is only use if tint is enabled
  50412. */
  50413. tintThickness: number;
  50414. private _tintTexture;
  50415. /**
  50416. * Stores the clear tint values in a texture.
  50417. * rgb is tint
  50418. * a is a thickness factor
  50419. */
  50420. tintTexture: Nullable<BaseTexture>;
  50421. /** @hidden */
  50422. private _internalMarkAllSubMeshesAsTexturesDirty;
  50423. /** @hidden */
  50424. _markAllSubMeshesAsTexturesDirty(): void;
  50425. /**
  50426. * Instantiate a new istance of clear coat configuration.
  50427. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50428. */
  50429. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50430. /**
  50431. * Gets wehter the submesh is ready to be used or not.
  50432. * @param defines the list of "defines" to update.
  50433. * @param scene defines the scene the material belongs to.
  50434. * @param engine defines the engine the material belongs to.
  50435. * @param disableBumpMap defines wether the material disables bump or not.
  50436. * @returns - boolean indicating that the submesh is ready or not.
  50437. */
  50438. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50439. /**
  50440. * Checks to see if a texture is used in the material.
  50441. * @param defines the list of "defines" to update.
  50442. * @param scene defines the scene to the material belongs to.
  50443. */
  50444. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50445. /**
  50446. * Binds the material data.
  50447. * @param uniformBuffer defines the Uniform buffer to fill in.
  50448. * @param scene defines the scene the material belongs to.
  50449. * @param engine defines the engine the material belongs to.
  50450. * @param disableBumpMap defines wether the material disables bump or not.
  50451. * @param isFrozen defines wether the material is frozen or not.
  50452. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50453. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50454. */
  50455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50456. /**
  50457. * Checks to see if a texture is used in the material.
  50458. * @param texture - Base texture to use.
  50459. * @returns - Boolean specifying if a texture is used in the material.
  50460. */
  50461. hasTexture(texture: BaseTexture): boolean;
  50462. /**
  50463. * Returns an array of the actively used textures.
  50464. * @param activeTextures Array of BaseTextures
  50465. */
  50466. getActiveTextures(activeTextures: BaseTexture[]): void;
  50467. /**
  50468. * Returns the animatable textures.
  50469. * @param animatables Array of animatable textures.
  50470. */
  50471. getAnimatables(animatables: IAnimatable[]): void;
  50472. /**
  50473. * Disposes the resources of the material.
  50474. * @param forceDisposeTextures - Forces the disposal of all textures.
  50475. */
  50476. dispose(forceDisposeTextures?: boolean): void;
  50477. /**
  50478. * Get the current class name of the texture useful for serialization or dynamic coding.
  50479. * @returns "PBRClearCoatConfiguration"
  50480. */
  50481. getClassName(): string;
  50482. /**
  50483. * Add fallbacks to the effect fallbacks list.
  50484. * @param defines defines the Base texture to use.
  50485. * @param fallbacks defines the current fallback list.
  50486. * @param currentRank defines the current fallback rank.
  50487. * @returns the new fallback rank.
  50488. */
  50489. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50490. /**
  50491. * Add the required uniforms to the current list.
  50492. * @param uniforms defines the current uniform list.
  50493. */
  50494. static AddUniforms(uniforms: string[]): void;
  50495. /**
  50496. * Add the required samplers to the current list.
  50497. * @param samplers defines the current sampler list.
  50498. */
  50499. static AddSamplers(samplers: string[]): void;
  50500. /**
  50501. * Add the required uniforms to the current buffer.
  50502. * @param uniformBuffer defines the current uniform buffer.
  50503. */
  50504. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50505. /**
  50506. * Makes a duplicate of the current configuration into another one.
  50507. * @param clearCoatConfiguration define the config where to copy the info
  50508. */
  50509. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50510. /**
  50511. * Serializes this clear coat configuration.
  50512. * @returns - An object with the serialized config.
  50513. */
  50514. serialize(): any;
  50515. /**
  50516. * Parses a anisotropy Configuration from a serialized object.
  50517. * @param source - Serialized object.
  50518. * @param scene Defines the scene we are parsing for
  50519. * @param rootUrl Defines the rootUrl to load from
  50520. */
  50521. parse(source: any, scene: Scene, rootUrl: string): void;
  50522. }
  50523. }
  50524. declare module BABYLON {
  50525. /**
  50526. * @hidden
  50527. */
  50528. export interface IMaterialAnisotropicDefines {
  50529. ANISOTROPIC: boolean;
  50530. ANISOTROPIC_TEXTURE: boolean;
  50531. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50532. MAINUV1: boolean;
  50533. _areTexturesDirty: boolean;
  50534. _needUVs: boolean;
  50535. }
  50536. /**
  50537. * Define the code related to the anisotropic parameters of the pbr material.
  50538. */
  50539. export class PBRAnisotropicConfiguration {
  50540. private _isEnabled;
  50541. /**
  50542. * Defines if the anisotropy is enabled in the material.
  50543. */
  50544. isEnabled: boolean;
  50545. /**
  50546. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50547. */
  50548. intensity: number;
  50549. /**
  50550. * Defines if the effect is along the tangents, bitangents or in between.
  50551. * By default, the effect is "strectching" the highlights along the tangents.
  50552. */
  50553. direction: Vector2;
  50554. private _texture;
  50555. /**
  50556. * Stores the anisotropy values in a texture.
  50557. * rg is direction (like normal from -1 to 1)
  50558. * b is a intensity
  50559. */
  50560. texture: Nullable<BaseTexture>;
  50561. /** @hidden */
  50562. private _internalMarkAllSubMeshesAsTexturesDirty;
  50563. /** @hidden */
  50564. _markAllSubMeshesAsTexturesDirty(): void;
  50565. /**
  50566. * Instantiate a new istance of anisotropy configuration.
  50567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50568. */
  50569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50570. /**
  50571. * Specifies that the submesh is ready to be used.
  50572. * @param defines the list of "defines" to update.
  50573. * @param scene defines the scene the material belongs to.
  50574. * @returns - boolean indicating that the submesh is ready or not.
  50575. */
  50576. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50577. /**
  50578. * Checks to see if a texture is used in the material.
  50579. * @param defines the list of "defines" to update.
  50580. * @param mesh the mesh we are preparing the defines for.
  50581. * @param scene defines the scene the material belongs to.
  50582. */
  50583. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50584. /**
  50585. * Binds the material data.
  50586. * @param uniformBuffer defines the Uniform buffer to fill in.
  50587. * @param scene defines the scene the material belongs to.
  50588. * @param isFrozen defines wether the material is frozen or not.
  50589. */
  50590. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50591. /**
  50592. * Checks to see if a texture is used in the material.
  50593. * @param texture - Base texture to use.
  50594. * @returns - Boolean specifying if a texture is used in the material.
  50595. */
  50596. hasTexture(texture: BaseTexture): boolean;
  50597. /**
  50598. * Returns an array of the actively used textures.
  50599. * @param activeTextures Array of BaseTextures
  50600. */
  50601. getActiveTextures(activeTextures: BaseTexture[]): void;
  50602. /**
  50603. * Returns the animatable textures.
  50604. * @param animatables Array of animatable textures.
  50605. */
  50606. getAnimatables(animatables: IAnimatable[]): void;
  50607. /**
  50608. * Disposes the resources of the material.
  50609. * @param forceDisposeTextures - Forces the disposal of all textures.
  50610. */
  50611. dispose(forceDisposeTextures?: boolean): void;
  50612. /**
  50613. * Get the current class name of the texture useful for serialization or dynamic coding.
  50614. * @returns "PBRAnisotropicConfiguration"
  50615. */
  50616. getClassName(): string;
  50617. /**
  50618. * Add fallbacks to the effect fallbacks list.
  50619. * @param defines defines the Base texture to use.
  50620. * @param fallbacks defines the current fallback list.
  50621. * @param currentRank defines the current fallback rank.
  50622. * @returns the new fallback rank.
  50623. */
  50624. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50625. /**
  50626. * Add the required uniforms to the current list.
  50627. * @param uniforms defines the current uniform list.
  50628. */
  50629. static AddUniforms(uniforms: string[]): void;
  50630. /**
  50631. * Add the required uniforms to the current buffer.
  50632. * @param uniformBuffer defines the current uniform buffer.
  50633. */
  50634. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50635. /**
  50636. * Add the required samplers to the current list.
  50637. * @param samplers defines the current sampler list.
  50638. */
  50639. static AddSamplers(samplers: string[]): void;
  50640. /**
  50641. * Makes a duplicate of the current configuration into another one.
  50642. * @param anisotropicConfiguration define the config where to copy the info
  50643. */
  50644. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50645. /**
  50646. * Serializes this anisotropy configuration.
  50647. * @returns - An object with the serialized config.
  50648. */
  50649. serialize(): any;
  50650. /**
  50651. * Parses a anisotropy Configuration from a serialized object.
  50652. * @param source - Serialized object.
  50653. * @param scene Defines the scene we are parsing for
  50654. * @param rootUrl Defines the rootUrl to load from
  50655. */
  50656. parse(source: any, scene: Scene, rootUrl: string): void;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * @hidden
  50662. */
  50663. export interface IMaterialBRDFDefines {
  50664. BRDF_V_HEIGHT_CORRELATED: boolean;
  50665. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50666. SPHERICAL_HARMONICS: boolean;
  50667. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50668. /** @hidden */
  50669. _areMiscDirty: boolean;
  50670. }
  50671. /**
  50672. * Define the code related to the BRDF parameters of the pbr material.
  50673. */
  50674. export class PBRBRDFConfiguration {
  50675. /**
  50676. * Default value used for the energy conservation.
  50677. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50678. */
  50679. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50680. /**
  50681. * Default value used for the Smith Visibility Height Correlated mode.
  50682. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50683. */
  50684. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50685. /**
  50686. * Default value used for the IBL diffuse part.
  50687. * This can help switching back to the polynomials mode globally which is a tiny bit
  50688. * less GPU intensive at the drawback of a lower quality.
  50689. */
  50690. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50691. /**
  50692. * Default value used for activating energy conservation for the specular workflow.
  50693. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50694. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50695. */
  50696. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50697. private _useEnergyConservation;
  50698. /**
  50699. * Defines if the material uses energy conservation.
  50700. */
  50701. useEnergyConservation: boolean;
  50702. private _useSmithVisibilityHeightCorrelated;
  50703. /**
  50704. * LEGACY Mode set to false
  50705. * Defines if the material uses height smith correlated visibility term.
  50706. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50707. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50708. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50709. * Not relying on height correlated will also disable energy conservation.
  50710. */
  50711. useSmithVisibilityHeightCorrelated: boolean;
  50712. private _useSphericalHarmonics;
  50713. /**
  50714. * LEGACY Mode set to false
  50715. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50716. * diffuse part of the IBL.
  50717. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50718. * to the ground truth.
  50719. */
  50720. useSphericalHarmonics: boolean;
  50721. private _useSpecularGlossinessInputEnergyConservation;
  50722. /**
  50723. * Defines if the material uses energy conservation, when the specular workflow is active.
  50724. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50725. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50726. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50727. */
  50728. useSpecularGlossinessInputEnergyConservation: boolean;
  50729. /** @hidden */
  50730. private _internalMarkAllSubMeshesAsMiscDirty;
  50731. /** @hidden */
  50732. _markAllSubMeshesAsMiscDirty(): void;
  50733. /**
  50734. * Instantiate a new istance of clear coat configuration.
  50735. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50736. */
  50737. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50738. /**
  50739. * Checks to see if a texture is used in the material.
  50740. * @param defines the list of "defines" to update.
  50741. */
  50742. prepareDefines(defines: IMaterialBRDFDefines): void;
  50743. /**
  50744. * Get the current class name of the texture useful for serialization or dynamic coding.
  50745. * @returns "PBRClearCoatConfiguration"
  50746. */
  50747. getClassName(): string;
  50748. /**
  50749. * Makes a duplicate of the current configuration into another one.
  50750. * @param brdfConfiguration define the config where to copy the info
  50751. */
  50752. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50753. /**
  50754. * Serializes this BRDF configuration.
  50755. * @returns - An object with the serialized config.
  50756. */
  50757. serialize(): any;
  50758. /**
  50759. * Parses a anisotropy Configuration from a serialized object.
  50760. * @param source - Serialized object.
  50761. * @param scene Defines the scene we are parsing for
  50762. * @param rootUrl Defines the rootUrl to load from
  50763. */
  50764. parse(source: any, scene: Scene, rootUrl: string): void;
  50765. }
  50766. }
  50767. declare module BABYLON {
  50768. /**
  50769. * @hidden
  50770. */
  50771. export interface IMaterialSheenDefines {
  50772. SHEEN: boolean;
  50773. SHEEN_TEXTURE: boolean;
  50774. SHEEN_TEXTUREDIRECTUV: number;
  50775. SHEEN_LINKWITHALBEDO: boolean;
  50776. SHEEN_ROUGHNESS: boolean;
  50777. SHEEN_ALBEDOSCALING: boolean;
  50778. /** @hidden */
  50779. _areTexturesDirty: boolean;
  50780. }
  50781. /**
  50782. * Define the code related to the Sheen parameters of the pbr material.
  50783. */
  50784. export class PBRSheenConfiguration {
  50785. private _isEnabled;
  50786. /**
  50787. * Defines if the material uses sheen.
  50788. */
  50789. isEnabled: boolean;
  50790. private _linkSheenWithAlbedo;
  50791. /**
  50792. * Defines if the sheen is linked to the sheen color.
  50793. */
  50794. linkSheenWithAlbedo: boolean;
  50795. /**
  50796. * Defines the sheen intensity.
  50797. */
  50798. intensity: number;
  50799. /**
  50800. * Defines the sheen color.
  50801. */
  50802. color: Color3;
  50803. private _texture;
  50804. /**
  50805. * Stores the sheen tint values in a texture.
  50806. * rgb is tint
  50807. * a is a intensity
  50808. */
  50809. texture: Nullable<BaseTexture>;
  50810. private _roughness;
  50811. /**
  50812. * Defines the sheen roughness.
  50813. * It is not taken into account if linkSheenWithAlbedo is true.
  50814. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50815. */
  50816. roughness: Nullable<number>;
  50817. private _albedoScaling;
  50818. /**
  50819. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50820. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50821. * making it easier to setup and tweak the effect
  50822. */
  50823. albedoScaling: boolean;
  50824. /** @hidden */
  50825. private _internalMarkAllSubMeshesAsTexturesDirty;
  50826. /** @hidden */
  50827. _markAllSubMeshesAsTexturesDirty(): void;
  50828. /**
  50829. * Instantiate a new istance of clear coat configuration.
  50830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50831. */
  50832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50833. /**
  50834. * Specifies that the submesh is ready to be used.
  50835. * @param defines the list of "defines" to update.
  50836. * @param scene defines the scene the material belongs to.
  50837. * @returns - boolean indicating that the submesh is ready or not.
  50838. */
  50839. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50840. /**
  50841. * Checks to see if a texture is used in the material.
  50842. * @param defines the list of "defines" to update.
  50843. * @param scene defines the scene the material belongs to.
  50844. */
  50845. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50846. /**
  50847. * Binds the material data.
  50848. * @param uniformBuffer defines the Uniform buffer to fill in.
  50849. * @param scene defines the scene the material belongs to.
  50850. * @param isFrozen defines wether the material is frozen or not.
  50851. */
  50852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50853. /**
  50854. * Checks to see if a texture is used in the material.
  50855. * @param texture - Base texture to use.
  50856. * @returns - Boolean specifying if a texture is used in the material.
  50857. */
  50858. hasTexture(texture: BaseTexture): boolean;
  50859. /**
  50860. * Returns an array of the actively used textures.
  50861. * @param activeTextures Array of BaseTextures
  50862. */
  50863. getActiveTextures(activeTextures: BaseTexture[]): void;
  50864. /**
  50865. * Returns the animatable textures.
  50866. * @param animatables Array of animatable textures.
  50867. */
  50868. getAnimatables(animatables: IAnimatable[]): void;
  50869. /**
  50870. * Disposes the resources of the material.
  50871. * @param forceDisposeTextures - Forces the disposal of all textures.
  50872. */
  50873. dispose(forceDisposeTextures?: boolean): void;
  50874. /**
  50875. * Get the current class name of the texture useful for serialization or dynamic coding.
  50876. * @returns "PBRSheenConfiguration"
  50877. */
  50878. getClassName(): string;
  50879. /**
  50880. * Add fallbacks to the effect fallbacks list.
  50881. * @param defines defines the Base texture to use.
  50882. * @param fallbacks defines the current fallback list.
  50883. * @param currentRank defines the current fallback rank.
  50884. * @returns the new fallback rank.
  50885. */
  50886. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50887. /**
  50888. * Add the required uniforms to the current list.
  50889. * @param uniforms defines the current uniform list.
  50890. */
  50891. static AddUniforms(uniforms: string[]): void;
  50892. /**
  50893. * Add the required uniforms to the current buffer.
  50894. * @param uniformBuffer defines the current uniform buffer.
  50895. */
  50896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50897. /**
  50898. * Add the required samplers to the current list.
  50899. * @param samplers defines the current sampler list.
  50900. */
  50901. static AddSamplers(samplers: string[]): void;
  50902. /**
  50903. * Makes a duplicate of the current configuration into another one.
  50904. * @param sheenConfiguration define the config where to copy the info
  50905. */
  50906. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50907. /**
  50908. * Serializes this BRDF configuration.
  50909. * @returns - An object with the serialized config.
  50910. */
  50911. serialize(): any;
  50912. /**
  50913. * Parses a anisotropy Configuration from a serialized object.
  50914. * @param source - Serialized object.
  50915. * @param scene Defines the scene we are parsing for
  50916. * @param rootUrl Defines the rootUrl to load from
  50917. */
  50918. parse(source: any, scene: Scene, rootUrl: string): void;
  50919. }
  50920. }
  50921. declare module BABYLON {
  50922. /**
  50923. * @hidden
  50924. */
  50925. export interface IMaterialSubSurfaceDefines {
  50926. SUBSURFACE: boolean;
  50927. SS_REFRACTION: boolean;
  50928. SS_TRANSLUCENCY: boolean;
  50929. SS_SCATERRING: boolean;
  50930. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50931. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50932. SS_REFRACTIONMAP_3D: boolean;
  50933. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50934. SS_LODINREFRACTIONALPHA: boolean;
  50935. SS_GAMMAREFRACTION: boolean;
  50936. SS_RGBDREFRACTION: boolean;
  50937. SS_LINEARSPECULARREFRACTION: boolean;
  50938. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50939. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50940. /** @hidden */
  50941. _areTexturesDirty: boolean;
  50942. }
  50943. /**
  50944. * Define the code related to the sub surface parameters of the pbr material.
  50945. */
  50946. export class PBRSubSurfaceConfiguration {
  50947. private _isRefractionEnabled;
  50948. /**
  50949. * Defines if the refraction is enabled in the material.
  50950. */
  50951. isRefractionEnabled: boolean;
  50952. private _isTranslucencyEnabled;
  50953. /**
  50954. * Defines if the translucency is enabled in the material.
  50955. */
  50956. isTranslucencyEnabled: boolean;
  50957. private _isScatteringEnabled;
  50958. /**
  50959. * Defines the refraction intensity of the material.
  50960. * The refraction when enabled replaces the Diffuse part of the material.
  50961. * The intensity helps transitionning between diffuse and refraction.
  50962. */
  50963. refractionIntensity: number;
  50964. /**
  50965. * Defines the translucency intensity of the material.
  50966. * When translucency has been enabled, this defines how much of the "translucency"
  50967. * is addded to the diffuse part of the material.
  50968. */
  50969. translucencyIntensity: number;
  50970. /**
  50971. * Defines the scattering intensity of the material.
  50972. * When scattering has been enabled, this defines how much of the "scattered light"
  50973. * is addded to the diffuse part of the material.
  50974. */
  50975. scatteringIntensity: number;
  50976. private _thicknessTexture;
  50977. /**
  50978. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50979. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50980. * 0 would mean minimumThickness
  50981. * 1 would mean maximumThickness
  50982. * The other channels might be use as a mask to vary the different effects intensity.
  50983. */
  50984. thicknessTexture: Nullable<BaseTexture>;
  50985. private _refractionTexture;
  50986. /**
  50987. * Defines the texture to use for refraction.
  50988. */
  50989. refractionTexture: Nullable<BaseTexture>;
  50990. private _indexOfRefraction;
  50991. /**
  50992. * Defines the index of refraction used in the material.
  50993. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50994. */
  50995. indexOfRefraction: number;
  50996. private _invertRefractionY;
  50997. /**
  50998. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50999. */
  51000. invertRefractionY: boolean;
  51001. private _linkRefractionWithTransparency;
  51002. /**
  51003. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51004. * Materials half opaque for instance using refraction could benefit from this control.
  51005. */
  51006. linkRefractionWithTransparency: boolean;
  51007. /**
  51008. * Defines the minimum thickness stored in the thickness map.
  51009. * If no thickness map is defined, this value will be used to simulate thickness.
  51010. */
  51011. minimumThickness: number;
  51012. /**
  51013. * Defines the maximum thickness stored in the thickness map.
  51014. */
  51015. maximumThickness: number;
  51016. /**
  51017. * Defines the volume tint of the material.
  51018. * This is used for both translucency and scattering.
  51019. */
  51020. tintColor: Color3;
  51021. /**
  51022. * Defines the distance at which the tint color should be found in the media.
  51023. * This is used for refraction only.
  51024. */
  51025. tintColorAtDistance: number;
  51026. /**
  51027. * Defines how far each channel transmit through the media.
  51028. * It is defined as a color to simplify it selection.
  51029. */
  51030. diffusionDistance: Color3;
  51031. private _useMaskFromThicknessTexture;
  51032. /**
  51033. * Stores the intensity of the different subsurface effects in the thickness texture.
  51034. * * the green channel is the translucency intensity.
  51035. * * the blue channel is the scattering intensity.
  51036. * * the alpha channel is the refraction intensity.
  51037. */
  51038. useMaskFromThicknessTexture: boolean;
  51039. /** @hidden */
  51040. private _internalMarkAllSubMeshesAsTexturesDirty;
  51041. /** @hidden */
  51042. _markAllSubMeshesAsTexturesDirty(): void;
  51043. /**
  51044. * Instantiate a new istance of sub surface configuration.
  51045. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51046. */
  51047. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51048. /**
  51049. * Gets wehter the submesh is ready to be used or not.
  51050. * @param defines the list of "defines" to update.
  51051. * @param scene defines the scene the material belongs to.
  51052. * @returns - boolean indicating that the submesh is ready or not.
  51053. */
  51054. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51055. /**
  51056. * Checks to see if a texture is used in the material.
  51057. * @param defines the list of "defines" to update.
  51058. * @param scene defines the scene to the material belongs to.
  51059. */
  51060. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51061. /**
  51062. * Binds the material data.
  51063. * @param uniformBuffer defines the Uniform buffer to fill in.
  51064. * @param scene defines the scene the material belongs to.
  51065. * @param engine defines the engine the material belongs to.
  51066. * @param isFrozen defines wether the material is frozen or not.
  51067. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51068. */
  51069. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51070. /**
  51071. * Unbinds the material from the mesh.
  51072. * @param activeEffect defines the effect that should be unbound from.
  51073. * @returns true if unbound, otherwise false
  51074. */
  51075. unbind(activeEffect: Effect): boolean;
  51076. /**
  51077. * Returns the texture used for refraction or null if none is used.
  51078. * @param scene defines the scene the material belongs to.
  51079. * @returns - Refraction texture if present. If no refraction texture and refraction
  51080. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51081. */
  51082. private _getRefractionTexture;
  51083. /**
  51084. * Returns true if alpha blending should be disabled.
  51085. */
  51086. get disableAlphaBlending(): boolean;
  51087. /**
  51088. * Fills the list of render target textures.
  51089. * @param renderTargets the list of render targets to update
  51090. */
  51091. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51092. /**
  51093. * Checks to see if a texture is used in the material.
  51094. * @param texture - Base texture to use.
  51095. * @returns - Boolean specifying if a texture is used in the material.
  51096. */
  51097. hasTexture(texture: BaseTexture): boolean;
  51098. /**
  51099. * Gets a boolean indicating that current material needs to register RTT
  51100. * @returns true if this uses a render target otherwise false.
  51101. */
  51102. hasRenderTargetTextures(): boolean;
  51103. /**
  51104. * Returns an array of the actively used textures.
  51105. * @param activeTextures Array of BaseTextures
  51106. */
  51107. getActiveTextures(activeTextures: BaseTexture[]): void;
  51108. /**
  51109. * Returns the animatable textures.
  51110. * @param animatables Array of animatable textures.
  51111. */
  51112. getAnimatables(animatables: IAnimatable[]): void;
  51113. /**
  51114. * Disposes the resources of the material.
  51115. * @param forceDisposeTextures - Forces the disposal of all textures.
  51116. */
  51117. dispose(forceDisposeTextures?: boolean): void;
  51118. /**
  51119. * Get the current class name of the texture useful for serialization or dynamic coding.
  51120. * @returns "PBRSubSurfaceConfiguration"
  51121. */
  51122. getClassName(): string;
  51123. /**
  51124. * Add fallbacks to the effect fallbacks list.
  51125. * @param defines defines the Base texture to use.
  51126. * @param fallbacks defines the current fallback list.
  51127. * @param currentRank defines the current fallback rank.
  51128. * @returns the new fallback rank.
  51129. */
  51130. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51131. /**
  51132. * Add the required uniforms to the current list.
  51133. * @param uniforms defines the current uniform list.
  51134. */
  51135. static AddUniforms(uniforms: string[]): void;
  51136. /**
  51137. * Add the required samplers to the current list.
  51138. * @param samplers defines the current sampler list.
  51139. */
  51140. static AddSamplers(samplers: string[]): void;
  51141. /**
  51142. * Add the required uniforms to the current buffer.
  51143. * @param uniformBuffer defines the current uniform buffer.
  51144. */
  51145. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51146. /**
  51147. * Makes a duplicate of the current configuration into another one.
  51148. * @param configuration define the config where to copy the info
  51149. */
  51150. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51151. /**
  51152. * Serializes this Sub Surface configuration.
  51153. * @returns - An object with the serialized config.
  51154. */
  51155. serialize(): any;
  51156. /**
  51157. * Parses a anisotropy Configuration from a serialized object.
  51158. * @param source - Serialized object.
  51159. * @param scene Defines the scene we are parsing for
  51160. * @param rootUrl Defines the rootUrl to load from
  51161. */
  51162. parse(source: any, scene: Scene, rootUrl: string): void;
  51163. }
  51164. }
  51165. declare module BABYLON {
  51166. /** @hidden */
  51167. export var pbrFragmentDeclaration: {
  51168. name: string;
  51169. shader: string;
  51170. };
  51171. }
  51172. declare module BABYLON {
  51173. /** @hidden */
  51174. export var pbrUboDeclaration: {
  51175. name: string;
  51176. shader: string;
  51177. };
  51178. }
  51179. declare module BABYLON {
  51180. /** @hidden */
  51181. export var pbrFragmentExtraDeclaration: {
  51182. name: string;
  51183. shader: string;
  51184. };
  51185. }
  51186. declare module BABYLON {
  51187. /** @hidden */
  51188. export var pbrFragmentSamplersDeclaration: {
  51189. name: string;
  51190. shader: string;
  51191. };
  51192. }
  51193. declare module BABYLON {
  51194. /** @hidden */
  51195. export var pbrHelperFunctions: {
  51196. name: string;
  51197. shader: string;
  51198. };
  51199. }
  51200. declare module BABYLON {
  51201. /** @hidden */
  51202. export var harmonicsFunctions: {
  51203. name: string;
  51204. shader: string;
  51205. };
  51206. }
  51207. declare module BABYLON {
  51208. /** @hidden */
  51209. export var pbrDirectLightingSetupFunctions: {
  51210. name: string;
  51211. shader: string;
  51212. };
  51213. }
  51214. declare module BABYLON {
  51215. /** @hidden */
  51216. export var pbrDirectLightingFalloffFunctions: {
  51217. name: string;
  51218. shader: string;
  51219. };
  51220. }
  51221. declare module BABYLON {
  51222. /** @hidden */
  51223. export var pbrBRDFFunctions: {
  51224. name: string;
  51225. shader: string;
  51226. };
  51227. }
  51228. declare module BABYLON {
  51229. /** @hidden */
  51230. export var pbrDirectLightingFunctions: {
  51231. name: string;
  51232. shader: string;
  51233. };
  51234. }
  51235. declare module BABYLON {
  51236. /** @hidden */
  51237. export var pbrIBLFunctions: {
  51238. name: string;
  51239. shader: string;
  51240. };
  51241. }
  51242. declare module BABYLON {
  51243. /** @hidden */
  51244. export var pbrBlockAlbedoOpacity: {
  51245. name: string;
  51246. shader: string;
  51247. };
  51248. }
  51249. declare module BABYLON {
  51250. /** @hidden */
  51251. export var pbrBlockReflectivity: {
  51252. name: string;
  51253. shader: string;
  51254. };
  51255. }
  51256. declare module BABYLON {
  51257. /** @hidden */
  51258. export var pbrBlockAmbientOcclusion: {
  51259. name: string;
  51260. shader: string;
  51261. };
  51262. }
  51263. declare module BABYLON {
  51264. /** @hidden */
  51265. export var pbrBlockAlphaFresnel: {
  51266. name: string;
  51267. shader: string;
  51268. };
  51269. }
  51270. declare module BABYLON {
  51271. /** @hidden */
  51272. export var pbrBlockAnisotropic: {
  51273. name: string;
  51274. shader: string;
  51275. };
  51276. }
  51277. declare module BABYLON {
  51278. /** @hidden */
  51279. export var pbrBlockReflection: {
  51280. name: string;
  51281. shader: string;
  51282. };
  51283. }
  51284. declare module BABYLON {
  51285. /** @hidden */
  51286. export var pbrBlockSheen: {
  51287. name: string;
  51288. shader: string;
  51289. };
  51290. }
  51291. declare module BABYLON {
  51292. /** @hidden */
  51293. export var pbrBlockClearcoat: {
  51294. name: string;
  51295. shader: string;
  51296. };
  51297. }
  51298. declare module BABYLON {
  51299. /** @hidden */
  51300. export var pbrBlockSubSurface: {
  51301. name: string;
  51302. shader: string;
  51303. };
  51304. }
  51305. declare module BABYLON {
  51306. /** @hidden */
  51307. export var pbrBlockNormalGeometric: {
  51308. name: string;
  51309. shader: string;
  51310. };
  51311. }
  51312. declare module BABYLON {
  51313. /** @hidden */
  51314. export var pbrBlockNormalFinal: {
  51315. name: string;
  51316. shader: string;
  51317. };
  51318. }
  51319. declare module BABYLON {
  51320. /** @hidden */
  51321. export var pbrBlockGeometryInfo: {
  51322. name: string;
  51323. shader: string;
  51324. };
  51325. }
  51326. declare module BABYLON {
  51327. /** @hidden */
  51328. export var pbrBlockReflectance0: {
  51329. name: string;
  51330. shader: string;
  51331. };
  51332. }
  51333. declare module BABYLON {
  51334. /** @hidden */
  51335. export var pbrBlockReflectance: {
  51336. name: string;
  51337. shader: string;
  51338. };
  51339. }
  51340. declare module BABYLON {
  51341. /** @hidden */
  51342. export var pbrBlockDirectLighting: {
  51343. name: string;
  51344. shader: string;
  51345. };
  51346. }
  51347. declare module BABYLON {
  51348. /** @hidden */
  51349. export var pbrBlockFinalLitComponents: {
  51350. name: string;
  51351. shader: string;
  51352. };
  51353. }
  51354. declare module BABYLON {
  51355. /** @hidden */
  51356. export var pbrBlockFinalUnlitComponents: {
  51357. name: string;
  51358. shader: string;
  51359. };
  51360. }
  51361. declare module BABYLON {
  51362. /** @hidden */
  51363. export var pbrBlockFinalColorComposition: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module BABYLON {
  51369. /** @hidden */
  51370. export var pbrBlockImageProcessing: {
  51371. name: string;
  51372. shader: string;
  51373. };
  51374. }
  51375. declare module BABYLON {
  51376. /** @hidden */
  51377. export var pbrDebug: {
  51378. name: string;
  51379. shader: string;
  51380. };
  51381. }
  51382. declare module BABYLON {
  51383. /** @hidden */
  51384. export var pbrPixelShader: {
  51385. name: string;
  51386. shader: string;
  51387. };
  51388. }
  51389. declare module BABYLON {
  51390. /** @hidden */
  51391. export var pbrVertexDeclaration: {
  51392. name: string;
  51393. shader: string;
  51394. };
  51395. }
  51396. declare module BABYLON {
  51397. /** @hidden */
  51398. export var pbrVertexShader: {
  51399. name: string;
  51400. shader: string;
  51401. };
  51402. }
  51403. declare module BABYLON {
  51404. /**
  51405. * Manages the defines for the PBR Material.
  51406. * @hidden
  51407. */
  51408. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51409. PBR: boolean;
  51410. MAINUV1: boolean;
  51411. MAINUV2: boolean;
  51412. UV1: boolean;
  51413. UV2: boolean;
  51414. ALBEDO: boolean;
  51415. GAMMAALBEDO: boolean;
  51416. ALBEDODIRECTUV: number;
  51417. VERTEXCOLOR: boolean;
  51418. AMBIENT: boolean;
  51419. AMBIENTDIRECTUV: number;
  51420. AMBIENTINGRAYSCALE: boolean;
  51421. OPACITY: boolean;
  51422. VERTEXALPHA: boolean;
  51423. OPACITYDIRECTUV: number;
  51424. OPACITYRGB: boolean;
  51425. ALPHATEST: boolean;
  51426. DEPTHPREPASS: boolean;
  51427. ALPHABLEND: boolean;
  51428. ALPHAFROMALBEDO: boolean;
  51429. ALPHATESTVALUE: string;
  51430. SPECULAROVERALPHA: boolean;
  51431. RADIANCEOVERALPHA: boolean;
  51432. ALPHAFRESNEL: boolean;
  51433. LINEARALPHAFRESNEL: boolean;
  51434. PREMULTIPLYALPHA: boolean;
  51435. EMISSIVE: boolean;
  51436. EMISSIVEDIRECTUV: number;
  51437. REFLECTIVITY: boolean;
  51438. REFLECTIVITYDIRECTUV: number;
  51439. SPECULARTERM: boolean;
  51440. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51441. MICROSURFACEAUTOMATIC: boolean;
  51442. LODBASEDMICROSFURACE: boolean;
  51443. MICROSURFACEMAP: boolean;
  51444. MICROSURFACEMAPDIRECTUV: number;
  51445. METALLICWORKFLOW: boolean;
  51446. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51447. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51448. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51449. AOSTOREINMETALMAPRED: boolean;
  51450. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51451. ENVIRONMENTBRDF: boolean;
  51452. ENVIRONMENTBRDF_RGBD: boolean;
  51453. NORMAL: boolean;
  51454. TANGENT: boolean;
  51455. BUMP: boolean;
  51456. BUMPDIRECTUV: number;
  51457. OBJECTSPACE_NORMALMAP: boolean;
  51458. PARALLAX: boolean;
  51459. PARALLAXOCCLUSION: boolean;
  51460. NORMALXYSCALE: boolean;
  51461. LIGHTMAP: boolean;
  51462. LIGHTMAPDIRECTUV: number;
  51463. USELIGHTMAPASSHADOWMAP: boolean;
  51464. GAMMALIGHTMAP: boolean;
  51465. RGBDLIGHTMAP: boolean;
  51466. REFLECTION: boolean;
  51467. REFLECTIONMAP_3D: boolean;
  51468. REFLECTIONMAP_SPHERICAL: boolean;
  51469. REFLECTIONMAP_PLANAR: boolean;
  51470. REFLECTIONMAP_CUBIC: boolean;
  51471. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51472. REFLECTIONMAP_PROJECTION: boolean;
  51473. REFLECTIONMAP_SKYBOX: boolean;
  51474. REFLECTIONMAP_EXPLICIT: boolean;
  51475. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51476. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51477. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51478. INVERTCUBICMAP: boolean;
  51479. USESPHERICALFROMREFLECTIONMAP: boolean;
  51480. USEIRRADIANCEMAP: boolean;
  51481. SPHERICAL_HARMONICS: boolean;
  51482. USESPHERICALINVERTEX: boolean;
  51483. REFLECTIONMAP_OPPOSITEZ: boolean;
  51484. LODINREFLECTIONALPHA: boolean;
  51485. GAMMAREFLECTION: boolean;
  51486. RGBDREFLECTION: boolean;
  51487. LINEARSPECULARREFLECTION: boolean;
  51488. RADIANCEOCCLUSION: boolean;
  51489. HORIZONOCCLUSION: boolean;
  51490. INSTANCES: boolean;
  51491. NUM_BONE_INFLUENCERS: number;
  51492. BonesPerMesh: number;
  51493. BONETEXTURE: boolean;
  51494. NONUNIFORMSCALING: boolean;
  51495. MORPHTARGETS: boolean;
  51496. MORPHTARGETS_NORMAL: boolean;
  51497. MORPHTARGETS_TANGENT: boolean;
  51498. MORPHTARGETS_UV: boolean;
  51499. NUM_MORPH_INFLUENCERS: number;
  51500. IMAGEPROCESSING: boolean;
  51501. VIGNETTE: boolean;
  51502. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51503. VIGNETTEBLENDMODEOPAQUE: boolean;
  51504. TONEMAPPING: boolean;
  51505. TONEMAPPING_ACES: boolean;
  51506. CONTRAST: boolean;
  51507. COLORCURVES: boolean;
  51508. COLORGRADING: boolean;
  51509. COLORGRADING3D: boolean;
  51510. SAMPLER3DGREENDEPTH: boolean;
  51511. SAMPLER3DBGRMAP: boolean;
  51512. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51513. EXPOSURE: boolean;
  51514. MULTIVIEW: boolean;
  51515. USEPHYSICALLIGHTFALLOFF: boolean;
  51516. USEGLTFLIGHTFALLOFF: boolean;
  51517. TWOSIDEDLIGHTING: boolean;
  51518. SHADOWFLOAT: boolean;
  51519. CLIPPLANE: boolean;
  51520. CLIPPLANE2: boolean;
  51521. CLIPPLANE3: boolean;
  51522. CLIPPLANE4: boolean;
  51523. CLIPPLANE5: boolean;
  51524. CLIPPLANE6: boolean;
  51525. POINTSIZE: boolean;
  51526. FOG: boolean;
  51527. LOGARITHMICDEPTH: boolean;
  51528. FORCENORMALFORWARD: boolean;
  51529. SPECULARAA: boolean;
  51530. CLEARCOAT: boolean;
  51531. CLEARCOAT_DEFAULTIOR: boolean;
  51532. CLEARCOAT_TEXTURE: boolean;
  51533. CLEARCOAT_TEXTUREDIRECTUV: number;
  51534. CLEARCOAT_BUMP: boolean;
  51535. CLEARCOAT_BUMPDIRECTUV: number;
  51536. CLEARCOAT_TINT: boolean;
  51537. CLEARCOAT_TINT_TEXTURE: boolean;
  51538. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51539. ANISOTROPIC: boolean;
  51540. ANISOTROPIC_TEXTURE: boolean;
  51541. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51542. BRDF_V_HEIGHT_CORRELATED: boolean;
  51543. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51544. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51545. SHEEN: boolean;
  51546. SHEEN_TEXTURE: boolean;
  51547. SHEEN_TEXTUREDIRECTUV: number;
  51548. SHEEN_LINKWITHALBEDO: boolean;
  51549. SHEEN_ROUGHNESS: boolean;
  51550. SHEEN_ALBEDOSCALING: boolean;
  51551. SUBSURFACE: boolean;
  51552. SS_REFRACTION: boolean;
  51553. SS_TRANSLUCENCY: boolean;
  51554. SS_SCATERRING: boolean;
  51555. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51556. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51557. SS_REFRACTIONMAP_3D: boolean;
  51558. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51559. SS_LODINREFRACTIONALPHA: boolean;
  51560. SS_GAMMAREFRACTION: boolean;
  51561. SS_RGBDREFRACTION: boolean;
  51562. SS_LINEARSPECULARREFRACTION: boolean;
  51563. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51564. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51565. UNLIT: boolean;
  51566. DEBUGMODE: number;
  51567. /**
  51568. * Initializes the PBR Material defines.
  51569. */
  51570. constructor();
  51571. /**
  51572. * Resets the PBR Material defines.
  51573. */
  51574. reset(): void;
  51575. }
  51576. /**
  51577. * The Physically based material base class of BJS.
  51578. *
  51579. * This offers the main features of a standard PBR material.
  51580. * For more information, please refer to the documentation :
  51581. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51582. */
  51583. export abstract class PBRBaseMaterial extends PushMaterial {
  51584. /**
  51585. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51586. */
  51587. static readonly PBRMATERIAL_OPAQUE: number;
  51588. /**
  51589. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51590. */
  51591. static readonly PBRMATERIAL_ALPHATEST: number;
  51592. /**
  51593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51594. */
  51595. static readonly PBRMATERIAL_ALPHABLEND: number;
  51596. /**
  51597. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51598. * They are also discarded below the alpha cutoff threshold to improve performances.
  51599. */
  51600. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51601. /**
  51602. * Defines the default value of how much AO map is occluding the analytical lights
  51603. * (point spot...).
  51604. */
  51605. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51606. /**
  51607. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51608. */
  51609. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51610. /**
  51611. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51612. * to enhance interoperability with other engines.
  51613. */
  51614. static readonly LIGHTFALLOFF_GLTF: number;
  51615. /**
  51616. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51617. * to enhance interoperability with other materials.
  51618. */
  51619. static readonly LIGHTFALLOFF_STANDARD: number;
  51620. /**
  51621. * Intensity of the direct lights e.g. the four lights available in your scene.
  51622. * This impacts both the direct diffuse and specular highlights.
  51623. */
  51624. protected _directIntensity: number;
  51625. /**
  51626. * Intensity of the emissive part of the material.
  51627. * This helps controlling the emissive effect without modifying the emissive color.
  51628. */
  51629. protected _emissiveIntensity: number;
  51630. /**
  51631. * Intensity of the environment e.g. how much the environment will light the object
  51632. * either through harmonics for rough material or through the refelction for shiny ones.
  51633. */
  51634. protected _environmentIntensity: number;
  51635. /**
  51636. * This is a special control allowing the reduction of the specular highlights coming from the
  51637. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51638. */
  51639. protected _specularIntensity: number;
  51640. /**
  51641. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51642. */
  51643. private _lightingInfos;
  51644. /**
  51645. * Debug Control allowing disabling the bump map on this material.
  51646. */
  51647. protected _disableBumpMap: boolean;
  51648. /**
  51649. * AKA Diffuse Texture in standard nomenclature.
  51650. */
  51651. protected _albedoTexture: Nullable<BaseTexture>;
  51652. /**
  51653. * AKA Occlusion Texture in other nomenclature.
  51654. */
  51655. protected _ambientTexture: Nullable<BaseTexture>;
  51656. /**
  51657. * AKA Occlusion Texture Intensity in other nomenclature.
  51658. */
  51659. protected _ambientTextureStrength: number;
  51660. /**
  51661. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51662. * 1 means it completely occludes it
  51663. * 0 mean it has no impact
  51664. */
  51665. protected _ambientTextureImpactOnAnalyticalLights: number;
  51666. /**
  51667. * Stores the alpha values in a texture.
  51668. */
  51669. protected _opacityTexture: Nullable<BaseTexture>;
  51670. /**
  51671. * Stores the reflection values in a texture.
  51672. */
  51673. protected _reflectionTexture: Nullable<BaseTexture>;
  51674. /**
  51675. * Stores the emissive values in a texture.
  51676. */
  51677. protected _emissiveTexture: Nullable<BaseTexture>;
  51678. /**
  51679. * AKA Specular texture in other nomenclature.
  51680. */
  51681. protected _reflectivityTexture: Nullable<BaseTexture>;
  51682. /**
  51683. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51684. */
  51685. protected _metallicTexture: Nullable<BaseTexture>;
  51686. /**
  51687. * Specifies the metallic scalar of the metallic/roughness workflow.
  51688. * Can also be used to scale the metalness values of the metallic texture.
  51689. */
  51690. protected _metallic: Nullable<number>;
  51691. /**
  51692. * Specifies the roughness scalar of the metallic/roughness workflow.
  51693. * Can also be used to scale the roughness values of the metallic texture.
  51694. */
  51695. protected _roughness: Nullable<number>;
  51696. /**
  51697. * Specifies the an F0 factor to help configuring the material F0.
  51698. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51699. * to 0.5 the previously hard coded value stays the same.
  51700. * Can also be used to scale the F0 values of the metallic texture.
  51701. */
  51702. protected _metallicF0Factor: number;
  51703. /**
  51704. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51705. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51706. * your expectation as it multiplies with the texture data.
  51707. */
  51708. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51709. /**
  51710. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51711. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51712. */
  51713. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51714. /**
  51715. * Stores surface normal data used to displace a mesh in a texture.
  51716. */
  51717. protected _bumpTexture: Nullable<BaseTexture>;
  51718. /**
  51719. * Stores the pre-calculated light information of a mesh in a texture.
  51720. */
  51721. protected _lightmapTexture: Nullable<BaseTexture>;
  51722. /**
  51723. * The color of a material in ambient lighting.
  51724. */
  51725. protected _ambientColor: Color3;
  51726. /**
  51727. * AKA Diffuse Color in other nomenclature.
  51728. */
  51729. protected _albedoColor: Color3;
  51730. /**
  51731. * AKA Specular Color in other nomenclature.
  51732. */
  51733. protected _reflectivityColor: Color3;
  51734. /**
  51735. * The color applied when light is reflected from a material.
  51736. */
  51737. protected _reflectionColor: Color3;
  51738. /**
  51739. * The color applied when light is emitted from a material.
  51740. */
  51741. protected _emissiveColor: Color3;
  51742. /**
  51743. * AKA Glossiness in other nomenclature.
  51744. */
  51745. protected _microSurface: number;
  51746. /**
  51747. * Specifies that the material will use the light map as a show map.
  51748. */
  51749. protected _useLightmapAsShadowmap: boolean;
  51750. /**
  51751. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51752. * makes the reflect vector face the model (under horizon).
  51753. */
  51754. protected _useHorizonOcclusion: boolean;
  51755. /**
  51756. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51757. * too much the area relying on ambient texture to define their ambient occlusion.
  51758. */
  51759. protected _useRadianceOcclusion: boolean;
  51760. /**
  51761. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51762. */
  51763. protected _useAlphaFromAlbedoTexture: boolean;
  51764. /**
  51765. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51766. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51767. */
  51768. protected _useSpecularOverAlpha: boolean;
  51769. /**
  51770. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51771. */
  51772. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51773. /**
  51774. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51775. */
  51776. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51777. /**
  51778. * Specifies if the metallic texture contains the roughness information in its green channel.
  51779. */
  51780. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51781. /**
  51782. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51783. */
  51784. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51785. /**
  51786. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51787. */
  51788. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51789. /**
  51790. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51791. */
  51792. protected _useAmbientInGrayScale: boolean;
  51793. /**
  51794. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51795. * The material will try to infer what glossiness each pixel should be.
  51796. */
  51797. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51798. /**
  51799. * Defines the falloff type used in this material.
  51800. * It by default is Physical.
  51801. */
  51802. protected _lightFalloff: number;
  51803. /**
  51804. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51805. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51806. */
  51807. protected _useRadianceOverAlpha: boolean;
  51808. /**
  51809. * Allows using an object space normal map (instead of tangent space).
  51810. */
  51811. protected _useObjectSpaceNormalMap: boolean;
  51812. /**
  51813. * Allows using the bump map in parallax mode.
  51814. */
  51815. protected _useParallax: boolean;
  51816. /**
  51817. * Allows using the bump map in parallax occlusion mode.
  51818. */
  51819. protected _useParallaxOcclusion: boolean;
  51820. /**
  51821. * Controls the scale bias of the parallax mode.
  51822. */
  51823. protected _parallaxScaleBias: number;
  51824. /**
  51825. * If sets to true, disables all the lights affecting the material.
  51826. */
  51827. protected _disableLighting: boolean;
  51828. /**
  51829. * Number of Simultaneous lights allowed on the material.
  51830. */
  51831. protected _maxSimultaneousLights: number;
  51832. /**
  51833. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51834. */
  51835. protected _invertNormalMapX: boolean;
  51836. /**
  51837. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51838. */
  51839. protected _invertNormalMapY: boolean;
  51840. /**
  51841. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51842. */
  51843. protected _twoSidedLighting: boolean;
  51844. /**
  51845. * Defines the alpha limits in alpha test mode.
  51846. */
  51847. protected _alphaCutOff: number;
  51848. /**
  51849. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51850. */
  51851. protected _forceAlphaTest: boolean;
  51852. /**
  51853. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51854. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51855. */
  51856. protected _useAlphaFresnel: boolean;
  51857. /**
  51858. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51859. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51860. */
  51861. protected _useLinearAlphaFresnel: boolean;
  51862. /**
  51863. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51864. * from cos thetav and roughness:
  51865. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51866. */
  51867. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51868. /**
  51869. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51870. */
  51871. protected _forceIrradianceInFragment: boolean;
  51872. /**
  51873. * Force normal to face away from face.
  51874. */
  51875. protected _forceNormalForward: boolean;
  51876. /**
  51877. * Enables specular anti aliasing in the PBR shader.
  51878. * It will both interacts on the Geometry for analytical and IBL lighting.
  51879. * It also prefilter the roughness map based on the bump values.
  51880. */
  51881. protected _enableSpecularAntiAliasing: boolean;
  51882. /**
  51883. * Default configuration related to image processing available in the PBR Material.
  51884. */
  51885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51886. /**
  51887. * Keep track of the image processing observer to allow dispose and replace.
  51888. */
  51889. private _imageProcessingObserver;
  51890. /**
  51891. * Attaches a new image processing configuration to the PBR Material.
  51892. * @param configuration
  51893. */
  51894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51895. /**
  51896. * Stores the available render targets.
  51897. */
  51898. private _renderTargets;
  51899. /**
  51900. * Sets the global ambient color for the material used in lighting calculations.
  51901. */
  51902. private _globalAmbientColor;
  51903. /**
  51904. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51905. */
  51906. private _useLogarithmicDepth;
  51907. /**
  51908. * If set to true, no lighting calculations will be applied.
  51909. */
  51910. private _unlit;
  51911. private _debugMode;
  51912. /**
  51913. * @hidden
  51914. * This is reserved for the inspector.
  51915. * Defines the material debug mode.
  51916. * It helps seeing only some components of the material while troubleshooting.
  51917. */
  51918. debugMode: number;
  51919. /**
  51920. * @hidden
  51921. * This is reserved for the inspector.
  51922. * Specify from where on screen the debug mode should start.
  51923. * The value goes from -1 (full screen) to 1 (not visible)
  51924. * It helps with side by side comparison against the final render
  51925. * This defaults to -1
  51926. */
  51927. private debugLimit;
  51928. /**
  51929. * @hidden
  51930. * This is reserved for the inspector.
  51931. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51932. * You can use the factor to better multiply the final value.
  51933. */
  51934. private debugFactor;
  51935. /**
  51936. * Defines the clear coat layer parameters for the material.
  51937. */
  51938. readonly clearCoat: PBRClearCoatConfiguration;
  51939. /**
  51940. * Defines the anisotropic parameters for the material.
  51941. */
  51942. readonly anisotropy: PBRAnisotropicConfiguration;
  51943. /**
  51944. * Defines the BRDF parameters for the material.
  51945. */
  51946. readonly brdf: PBRBRDFConfiguration;
  51947. /**
  51948. * Defines the Sheen parameters for the material.
  51949. */
  51950. readonly sheen: PBRSheenConfiguration;
  51951. /**
  51952. * Defines the SubSurface parameters for the material.
  51953. */
  51954. readonly subSurface: PBRSubSurfaceConfiguration;
  51955. /**
  51956. * Custom callback helping to override the default shader used in the material.
  51957. */
  51958. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51959. protected _rebuildInParallel: boolean;
  51960. /**
  51961. * Instantiates a new PBRMaterial instance.
  51962. *
  51963. * @param name The material name
  51964. * @param scene The scene the material will be use in.
  51965. */
  51966. constructor(name: string, scene: Scene);
  51967. /**
  51968. * Gets a boolean indicating that current material needs to register RTT
  51969. */
  51970. get hasRenderTargetTextures(): boolean;
  51971. /**
  51972. * Gets the name of the material class.
  51973. */
  51974. getClassName(): string;
  51975. /**
  51976. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51977. */
  51978. get useLogarithmicDepth(): boolean;
  51979. /**
  51980. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51981. */
  51982. set useLogarithmicDepth(value: boolean);
  51983. /**
  51984. * Returns true if alpha blending should be disabled.
  51985. */
  51986. protected get _disableAlphaBlending(): boolean;
  51987. /**
  51988. * Specifies whether or not this material should be rendered in alpha blend mode.
  51989. */
  51990. needAlphaBlending(): boolean;
  51991. /**
  51992. * Specifies whether or not this material should be rendered in alpha test mode.
  51993. */
  51994. needAlphaTesting(): boolean;
  51995. /**
  51996. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51997. */
  51998. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51999. /**
  52000. * Gets the texture used for the alpha test.
  52001. */
  52002. getAlphaTestTexture(): Nullable<BaseTexture>;
  52003. /**
  52004. * Specifies that the submesh is ready to be used.
  52005. * @param mesh - BJS mesh.
  52006. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52007. * @param useInstances - Specifies that instances should be used.
  52008. * @returns - boolean indicating that the submesh is ready or not.
  52009. */
  52010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52011. /**
  52012. * Specifies if the material uses metallic roughness workflow.
  52013. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52014. */
  52015. isMetallicWorkflow(): boolean;
  52016. private _prepareEffect;
  52017. private _prepareDefines;
  52018. /**
  52019. * Force shader compilation
  52020. */
  52021. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52022. /**
  52023. * Initializes the uniform buffer layout for the shader.
  52024. */
  52025. buildUniformLayout(): void;
  52026. /**
  52027. * Unbinds the material from the mesh
  52028. */
  52029. unbind(): void;
  52030. /**
  52031. * Binds the submesh data.
  52032. * @param world - The world matrix.
  52033. * @param mesh - The BJS mesh.
  52034. * @param subMesh - A submesh of the BJS mesh.
  52035. */
  52036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52037. /**
  52038. * Returns the animatable textures.
  52039. * @returns - Array of animatable textures.
  52040. */
  52041. getAnimatables(): IAnimatable[];
  52042. /**
  52043. * Returns the texture used for reflections.
  52044. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52045. */
  52046. private _getReflectionTexture;
  52047. /**
  52048. * Returns an array of the actively used textures.
  52049. * @returns - Array of BaseTextures
  52050. */
  52051. getActiveTextures(): BaseTexture[];
  52052. /**
  52053. * Checks to see if a texture is used in the material.
  52054. * @param texture - Base texture to use.
  52055. * @returns - Boolean specifying if a texture is used in the material.
  52056. */
  52057. hasTexture(texture: BaseTexture): boolean;
  52058. /**
  52059. * Disposes the resources of the material.
  52060. * @param forceDisposeEffect - Forces the disposal of effects.
  52061. * @param forceDisposeTextures - Forces the disposal of all textures.
  52062. */
  52063. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52064. }
  52065. }
  52066. declare module BABYLON {
  52067. /**
  52068. * The Physically based material of BJS.
  52069. *
  52070. * This offers the main features of a standard PBR material.
  52071. * For more information, please refer to the documentation :
  52072. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52073. */
  52074. export class PBRMaterial extends PBRBaseMaterial {
  52075. /**
  52076. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52077. */
  52078. static readonly PBRMATERIAL_OPAQUE: number;
  52079. /**
  52080. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52081. */
  52082. static readonly PBRMATERIAL_ALPHATEST: number;
  52083. /**
  52084. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52085. */
  52086. static readonly PBRMATERIAL_ALPHABLEND: number;
  52087. /**
  52088. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52089. * They are also discarded below the alpha cutoff threshold to improve performances.
  52090. */
  52091. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52092. /**
  52093. * Defines the default value of how much AO map is occluding the analytical lights
  52094. * (point spot...).
  52095. */
  52096. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52097. /**
  52098. * Intensity of the direct lights e.g. the four lights available in your scene.
  52099. * This impacts both the direct diffuse and specular highlights.
  52100. */
  52101. directIntensity: number;
  52102. /**
  52103. * Intensity of the emissive part of the material.
  52104. * This helps controlling the emissive effect without modifying the emissive color.
  52105. */
  52106. emissiveIntensity: number;
  52107. /**
  52108. * Intensity of the environment e.g. how much the environment will light the object
  52109. * either through harmonics for rough material or through the refelction for shiny ones.
  52110. */
  52111. environmentIntensity: number;
  52112. /**
  52113. * This is a special control allowing the reduction of the specular highlights coming from the
  52114. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52115. */
  52116. specularIntensity: number;
  52117. /**
  52118. * Debug Control allowing disabling the bump map on this material.
  52119. */
  52120. disableBumpMap: boolean;
  52121. /**
  52122. * AKA Diffuse Texture in standard nomenclature.
  52123. */
  52124. albedoTexture: BaseTexture;
  52125. /**
  52126. * AKA Occlusion Texture in other nomenclature.
  52127. */
  52128. ambientTexture: BaseTexture;
  52129. /**
  52130. * AKA Occlusion Texture Intensity in other nomenclature.
  52131. */
  52132. ambientTextureStrength: number;
  52133. /**
  52134. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52135. * 1 means it completely occludes it
  52136. * 0 mean it has no impact
  52137. */
  52138. ambientTextureImpactOnAnalyticalLights: number;
  52139. /**
  52140. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52141. */
  52142. opacityTexture: BaseTexture;
  52143. /**
  52144. * Stores the reflection values in a texture.
  52145. */
  52146. reflectionTexture: Nullable<BaseTexture>;
  52147. /**
  52148. * Stores the emissive values in a texture.
  52149. */
  52150. emissiveTexture: BaseTexture;
  52151. /**
  52152. * AKA Specular texture in other nomenclature.
  52153. */
  52154. reflectivityTexture: BaseTexture;
  52155. /**
  52156. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52157. */
  52158. metallicTexture: BaseTexture;
  52159. /**
  52160. * Specifies the metallic scalar of the metallic/roughness workflow.
  52161. * Can also be used to scale the metalness values of the metallic texture.
  52162. */
  52163. metallic: Nullable<number>;
  52164. /**
  52165. * Specifies the roughness scalar of the metallic/roughness workflow.
  52166. * Can also be used to scale the roughness values of the metallic texture.
  52167. */
  52168. roughness: Nullable<number>;
  52169. /**
  52170. * Specifies the an F0 factor to help configuring the material F0.
  52171. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52172. * to 0.5 the previously hard coded value stays the same.
  52173. * Can also be used to scale the F0 values of the metallic texture.
  52174. */
  52175. metallicF0Factor: number;
  52176. /**
  52177. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52178. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52179. * your expectation as it multiplies with the texture data.
  52180. */
  52181. useMetallicF0FactorFromMetallicTexture: boolean;
  52182. /**
  52183. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52184. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52185. */
  52186. microSurfaceTexture: BaseTexture;
  52187. /**
  52188. * Stores surface normal data used to displace a mesh in a texture.
  52189. */
  52190. bumpTexture: BaseTexture;
  52191. /**
  52192. * Stores the pre-calculated light information of a mesh in a texture.
  52193. */
  52194. lightmapTexture: BaseTexture;
  52195. /**
  52196. * Stores the refracted light information in a texture.
  52197. */
  52198. get refractionTexture(): Nullable<BaseTexture>;
  52199. set refractionTexture(value: Nullable<BaseTexture>);
  52200. /**
  52201. * The color of a material in ambient lighting.
  52202. */
  52203. ambientColor: Color3;
  52204. /**
  52205. * AKA Diffuse Color in other nomenclature.
  52206. */
  52207. albedoColor: Color3;
  52208. /**
  52209. * AKA Specular Color in other nomenclature.
  52210. */
  52211. reflectivityColor: Color3;
  52212. /**
  52213. * The color reflected from the material.
  52214. */
  52215. reflectionColor: Color3;
  52216. /**
  52217. * The color emitted from the material.
  52218. */
  52219. emissiveColor: Color3;
  52220. /**
  52221. * AKA Glossiness in other nomenclature.
  52222. */
  52223. microSurface: number;
  52224. /**
  52225. * source material index of refraction (IOR)' / 'destination material IOR.
  52226. */
  52227. get indexOfRefraction(): number;
  52228. set indexOfRefraction(value: number);
  52229. /**
  52230. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52231. */
  52232. get invertRefractionY(): boolean;
  52233. set invertRefractionY(value: boolean);
  52234. /**
  52235. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52236. * Materials half opaque for instance using refraction could benefit from this control.
  52237. */
  52238. get linkRefractionWithTransparency(): boolean;
  52239. set linkRefractionWithTransparency(value: boolean);
  52240. /**
  52241. * If true, the light map contains occlusion information instead of lighting info.
  52242. */
  52243. useLightmapAsShadowmap: boolean;
  52244. /**
  52245. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52246. */
  52247. useAlphaFromAlbedoTexture: boolean;
  52248. /**
  52249. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52250. */
  52251. forceAlphaTest: boolean;
  52252. /**
  52253. * Defines the alpha limits in alpha test mode.
  52254. */
  52255. alphaCutOff: number;
  52256. /**
  52257. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52258. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52259. */
  52260. useSpecularOverAlpha: boolean;
  52261. /**
  52262. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52263. */
  52264. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52265. /**
  52266. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52267. */
  52268. useRoughnessFromMetallicTextureAlpha: boolean;
  52269. /**
  52270. * Specifies if the metallic texture contains the roughness information in its green channel.
  52271. */
  52272. useRoughnessFromMetallicTextureGreen: boolean;
  52273. /**
  52274. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52275. */
  52276. useMetallnessFromMetallicTextureBlue: boolean;
  52277. /**
  52278. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52279. */
  52280. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52281. /**
  52282. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52283. */
  52284. useAmbientInGrayScale: boolean;
  52285. /**
  52286. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52287. * The material will try to infer what glossiness each pixel should be.
  52288. */
  52289. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52290. /**
  52291. * BJS is using an harcoded light falloff based on a manually sets up range.
  52292. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52293. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52294. */
  52295. get usePhysicalLightFalloff(): boolean;
  52296. /**
  52297. * BJS is using an harcoded light falloff based on a manually sets up range.
  52298. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52299. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52300. */
  52301. set usePhysicalLightFalloff(value: boolean);
  52302. /**
  52303. * In order to support the falloff compatibility with gltf, a special mode has been added
  52304. * to reproduce the gltf light falloff.
  52305. */
  52306. get useGLTFLightFalloff(): boolean;
  52307. /**
  52308. * In order to support the falloff compatibility with gltf, a special mode has been added
  52309. * to reproduce the gltf light falloff.
  52310. */
  52311. set useGLTFLightFalloff(value: boolean);
  52312. /**
  52313. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52314. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52315. */
  52316. useRadianceOverAlpha: boolean;
  52317. /**
  52318. * Allows using an object space normal map (instead of tangent space).
  52319. */
  52320. useObjectSpaceNormalMap: boolean;
  52321. /**
  52322. * Allows using the bump map in parallax mode.
  52323. */
  52324. useParallax: boolean;
  52325. /**
  52326. * Allows using the bump map in parallax occlusion mode.
  52327. */
  52328. useParallaxOcclusion: boolean;
  52329. /**
  52330. * Controls the scale bias of the parallax mode.
  52331. */
  52332. parallaxScaleBias: number;
  52333. /**
  52334. * If sets to true, disables all the lights affecting the material.
  52335. */
  52336. disableLighting: boolean;
  52337. /**
  52338. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52339. */
  52340. forceIrradianceInFragment: boolean;
  52341. /**
  52342. * Number of Simultaneous lights allowed on the material.
  52343. */
  52344. maxSimultaneousLights: number;
  52345. /**
  52346. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52347. */
  52348. invertNormalMapX: boolean;
  52349. /**
  52350. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52351. */
  52352. invertNormalMapY: boolean;
  52353. /**
  52354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52355. */
  52356. twoSidedLighting: boolean;
  52357. /**
  52358. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52359. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52360. */
  52361. useAlphaFresnel: boolean;
  52362. /**
  52363. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52364. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52365. */
  52366. useLinearAlphaFresnel: boolean;
  52367. /**
  52368. * Let user defines the brdf lookup texture used for IBL.
  52369. * A default 8bit version is embedded but you could point at :
  52370. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52371. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52372. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52373. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52374. */
  52375. environmentBRDFTexture: Nullable<BaseTexture>;
  52376. /**
  52377. * Force normal to face away from face.
  52378. */
  52379. forceNormalForward: boolean;
  52380. /**
  52381. * Enables specular anti aliasing in the PBR shader.
  52382. * It will both interacts on the Geometry for analytical and IBL lighting.
  52383. * It also prefilter the roughness map based on the bump values.
  52384. */
  52385. enableSpecularAntiAliasing: boolean;
  52386. /**
  52387. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52388. * makes the reflect vector face the model (under horizon).
  52389. */
  52390. useHorizonOcclusion: boolean;
  52391. /**
  52392. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52393. * too much the area relying on ambient texture to define their ambient occlusion.
  52394. */
  52395. useRadianceOcclusion: boolean;
  52396. /**
  52397. * If set to true, no lighting calculations will be applied.
  52398. */
  52399. unlit: boolean;
  52400. /**
  52401. * Gets the image processing configuration used either in this material.
  52402. */
  52403. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52404. /**
  52405. * Sets the Default image processing configuration used either in the this material.
  52406. *
  52407. * If sets to null, the scene one is in use.
  52408. */
  52409. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52410. /**
  52411. * Gets wether the color curves effect is enabled.
  52412. */
  52413. get cameraColorCurvesEnabled(): boolean;
  52414. /**
  52415. * Sets wether the color curves effect is enabled.
  52416. */
  52417. set cameraColorCurvesEnabled(value: boolean);
  52418. /**
  52419. * Gets wether the color grading effect is enabled.
  52420. */
  52421. get cameraColorGradingEnabled(): boolean;
  52422. /**
  52423. * Gets wether the color grading effect is enabled.
  52424. */
  52425. set cameraColorGradingEnabled(value: boolean);
  52426. /**
  52427. * Gets wether tonemapping is enabled or not.
  52428. */
  52429. get cameraToneMappingEnabled(): boolean;
  52430. /**
  52431. * Sets wether tonemapping is enabled or not
  52432. */
  52433. set cameraToneMappingEnabled(value: boolean);
  52434. /**
  52435. * The camera exposure used on this material.
  52436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52437. * This corresponds to a photographic exposure.
  52438. */
  52439. get cameraExposure(): number;
  52440. /**
  52441. * The camera exposure used on this material.
  52442. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52443. * This corresponds to a photographic exposure.
  52444. */
  52445. set cameraExposure(value: number);
  52446. /**
  52447. * Gets The camera contrast used on this material.
  52448. */
  52449. get cameraContrast(): number;
  52450. /**
  52451. * Sets The camera contrast used on this material.
  52452. */
  52453. set cameraContrast(value: number);
  52454. /**
  52455. * Gets the Color Grading 2D Lookup Texture.
  52456. */
  52457. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52458. /**
  52459. * Sets the Color Grading 2D Lookup Texture.
  52460. */
  52461. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52462. /**
  52463. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52464. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52465. * 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;
  52466. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52467. */
  52468. get cameraColorCurves(): Nullable<ColorCurves>;
  52469. /**
  52470. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52471. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52472. * 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;
  52473. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52474. */
  52475. set cameraColorCurves(value: Nullable<ColorCurves>);
  52476. /**
  52477. * Instantiates a new PBRMaterial instance.
  52478. *
  52479. * @param name The material name
  52480. * @param scene The scene the material will be use in.
  52481. */
  52482. constructor(name: string, scene: Scene);
  52483. /**
  52484. * Returns the name of this material class.
  52485. */
  52486. getClassName(): string;
  52487. /**
  52488. * Makes a duplicate of the current material.
  52489. * @param name - name to use for the new material.
  52490. */
  52491. clone(name: string): PBRMaterial;
  52492. /**
  52493. * Serializes this PBR Material.
  52494. * @returns - An object with the serialized material.
  52495. */
  52496. serialize(): any;
  52497. /**
  52498. * Parses a PBR Material from a serialized object.
  52499. * @param source - Serialized object.
  52500. * @param scene - BJS scene instance.
  52501. * @param rootUrl - url for the scene object
  52502. * @returns - PBRMaterial
  52503. */
  52504. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52505. }
  52506. }
  52507. declare module BABYLON {
  52508. /**
  52509. * Direct draw surface info
  52510. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52511. */
  52512. export interface DDSInfo {
  52513. /**
  52514. * Width of the texture
  52515. */
  52516. width: number;
  52517. /**
  52518. * Width of the texture
  52519. */
  52520. height: number;
  52521. /**
  52522. * Number of Mipmaps for the texture
  52523. * @see https://en.wikipedia.org/wiki/Mipmap
  52524. */
  52525. mipmapCount: number;
  52526. /**
  52527. * If the textures format is a known fourCC format
  52528. * @see https://www.fourcc.org/
  52529. */
  52530. isFourCC: boolean;
  52531. /**
  52532. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52533. */
  52534. isRGB: boolean;
  52535. /**
  52536. * If the texture is a lumincance format
  52537. */
  52538. isLuminance: boolean;
  52539. /**
  52540. * If this is a cube texture
  52541. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52542. */
  52543. isCube: boolean;
  52544. /**
  52545. * If the texture is a compressed format eg. FOURCC_DXT1
  52546. */
  52547. isCompressed: boolean;
  52548. /**
  52549. * The dxgiFormat of the texture
  52550. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52551. */
  52552. dxgiFormat: number;
  52553. /**
  52554. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52555. */
  52556. textureType: number;
  52557. /**
  52558. * Sphericle polynomial created for the dds texture
  52559. */
  52560. sphericalPolynomial?: SphericalPolynomial;
  52561. }
  52562. /**
  52563. * Class used to provide DDS decompression tools
  52564. */
  52565. export class DDSTools {
  52566. /**
  52567. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52568. */
  52569. static StoreLODInAlphaChannel: boolean;
  52570. /**
  52571. * Gets DDS information from an array buffer
  52572. * @param data defines the array buffer view to read data from
  52573. * @returns the DDS information
  52574. */
  52575. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52576. private static _FloatView;
  52577. private static _Int32View;
  52578. private static _ToHalfFloat;
  52579. private static _FromHalfFloat;
  52580. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52581. private static _GetHalfFloatRGBAArrayBuffer;
  52582. private static _GetFloatRGBAArrayBuffer;
  52583. private static _GetFloatAsUIntRGBAArrayBuffer;
  52584. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52585. private static _GetRGBAArrayBuffer;
  52586. private static _ExtractLongWordOrder;
  52587. private static _GetRGBArrayBuffer;
  52588. private static _GetLuminanceArrayBuffer;
  52589. /**
  52590. * Uploads DDS Levels to a Babylon Texture
  52591. * @hidden
  52592. */
  52593. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52594. }
  52595. interface ThinEngine {
  52596. /**
  52597. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52598. * @param rootUrl defines the url where the file to load is located
  52599. * @param scene defines the current scene
  52600. * @param lodScale defines scale to apply to the mip map selection
  52601. * @param lodOffset defines offset to apply to the mip map selection
  52602. * @param onLoad defines an optional callback raised when the texture is loaded
  52603. * @param onError defines an optional callback raised if there is an issue to load the texture
  52604. * @param format defines the format of the data
  52605. * @param forcedExtension defines the extension to use to pick the right loader
  52606. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52607. * @returns the cube texture as an InternalTexture
  52608. */
  52609. 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;
  52610. }
  52611. }
  52612. declare module BABYLON {
  52613. /**
  52614. * Implementation of the DDS Texture Loader.
  52615. * @hidden
  52616. */
  52617. export class _DDSTextureLoader implements IInternalTextureLoader {
  52618. /**
  52619. * Defines wether the loader supports cascade loading the different faces.
  52620. */
  52621. readonly supportCascades: boolean;
  52622. /**
  52623. * This returns if the loader support the current file information.
  52624. * @param extension defines the file extension of the file being loaded
  52625. * @returns true if the loader can load the specified file
  52626. */
  52627. canLoad(extension: string): boolean;
  52628. /**
  52629. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52630. * @param data contains the texture data
  52631. * @param texture defines the BabylonJS internal texture
  52632. * @param createPolynomials will be true if polynomials have been requested
  52633. * @param onLoad defines the callback to trigger once the texture is ready
  52634. * @param onError defines the callback to trigger in case of error
  52635. */
  52636. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52637. /**
  52638. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52639. * @param data contains the texture data
  52640. * @param texture defines the BabylonJS internal texture
  52641. * @param callback defines the method to call once ready to upload
  52642. */
  52643. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52644. }
  52645. }
  52646. declare module BABYLON {
  52647. /**
  52648. * Implementation of the ENV Texture Loader.
  52649. * @hidden
  52650. */
  52651. export class _ENVTextureLoader implements IInternalTextureLoader {
  52652. /**
  52653. * Defines wether the loader supports cascade loading the different faces.
  52654. */
  52655. readonly supportCascades: boolean;
  52656. /**
  52657. * This returns if the loader support the current file information.
  52658. * @param extension defines the file extension of the file being loaded
  52659. * @returns true if the loader can load the specified file
  52660. */
  52661. canLoad(extension: string): boolean;
  52662. /**
  52663. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52664. * @param data contains the texture data
  52665. * @param texture defines the BabylonJS internal texture
  52666. * @param createPolynomials will be true if polynomials have been requested
  52667. * @param onLoad defines the callback to trigger once the texture is ready
  52668. * @param onError defines the callback to trigger in case of error
  52669. */
  52670. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52671. /**
  52672. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52673. * @param data contains the texture data
  52674. * @param texture defines the BabylonJS internal texture
  52675. * @param callback defines the method to call once ready to upload
  52676. */
  52677. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52678. }
  52679. }
  52680. declare module BABYLON {
  52681. /**
  52682. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52683. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52684. */
  52685. export class KhronosTextureContainer {
  52686. /** contents of the KTX container file */
  52687. data: ArrayBufferView;
  52688. private static HEADER_LEN;
  52689. private static COMPRESSED_2D;
  52690. private static COMPRESSED_3D;
  52691. private static TEX_2D;
  52692. private static TEX_3D;
  52693. /**
  52694. * Gets the openGL type
  52695. */
  52696. glType: number;
  52697. /**
  52698. * Gets the openGL type size
  52699. */
  52700. glTypeSize: number;
  52701. /**
  52702. * Gets the openGL format
  52703. */
  52704. glFormat: number;
  52705. /**
  52706. * Gets the openGL internal format
  52707. */
  52708. glInternalFormat: number;
  52709. /**
  52710. * Gets the base internal format
  52711. */
  52712. glBaseInternalFormat: number;
  52713. /**
  52714. * Gets image width in pixel
  52715. */
  52716. pixelWidth: number;
  52717. /**
  52718. * Gets image height in pixel
  52719. */
  52720. pixelHeight: number;
  52721. /**
  52722. * Gets image depth in pixels
  52723. */
  52724. pixelDepth: number;
  52725. /**
  52726. * Gets the number of array elements
  52727. */
  52728. numberOfArrayElements: number;
  52729. /**
  52730. * Gets the number of faces
  52731. */
  52732. numberOfFaces: number;
  52733. /**
  52734. * Gets the number of mipmap levels
  52735. */
  52736. numberOfMipmapLevels: number;
  52737. /**
  52738. * Gets the bytes of key value data
  52739. */
  52740. bytesOfKeyValueData: number;
  52741. /**
  52742. * Gets the load type
  52743. */
  52744. loadType: number;
  52745. /**
  52746. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52747. */
  52748. isInvalid: boolean;
  52749. /**
  52750. * Creates a new KhronosTextureContainer
  52751. * @param data contents of the KTX container file
  52752. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52753. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52754. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52755. */
  52756. constructor(
  52757. /** contents of the KTX container file */
  52758. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52759. /**
  52760. * Uploads KTX content to a Babylon Texture.
  52761. * It is assumed that the texture has already been created & is currently bound
  52762. * @hidden
  52763. */
  52764. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52765. private _upload2DCompressedLevels;
  52766. /**
  52767. * Checks if the given data starts with a KTX file identifier.
  52768. * @param data the data to check
  52769. * @returns true if the data is a KTX file or false otherwise
  52770. */
  52771. static IsValid(data: ArrayBufferView): boolean;
  52772. }
  52773. }
  52774. declare module BABYLON {
  52775. /**
  52776. * Class for loading KTX2 files
  52777. * !!! Experimental Extension Subject to Changes !!!
  52778. * @hidden
  52779. */
  52780. export class KhronosTextureContainer2 {
  52781. private static _ModulePromise;
  52782. private static _TranscodeFormat;
  52783. constructor(engine: ThinEngine);
  52784. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52785. private _determineTranscodeFormat;
  52786. /**
  52787. * Checks if the given data starts with a KTX2 file identifier.
  52788. * @param data the data to check
  52789. * @returns true if the data is a KTX2 file or false otherwise
  52790. */
  52791. static IsValid(data: ArrayBufferView): boolean;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Implementation of the KTX Texture Loader.
  52797. * @hidden
  52798. */
  52799. export class _KTXTextureLoader implements IInternalTextureLoader {
  52800. /**
  52801. * Defines wether the loader supports cascade loading the different faces.
  52802. */
  52803. readonly supportCascades: boolean;
  52804. /**
  52805. * This returns if the loader support the current file information.
  52806. * @param extension defines the file extension of the file being loaded
  52807. * @returns true if the loader can load the specified file
  52808. */
  52809. canLoad(extension: string): boolean;
  52810. /**
  52811. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52812. * @param data contains the texture data
  52813. * @param texture defines the BabylonJS internal texture
  52814. * @param createPolynomials will be true if polynomials have been requested
  52815. * @param onLoad defines the callback to trigger once the texture is ready
  52816. * @param onError defines the callback to trigger in case of error
  52817. */
  52818. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52819. /**
  52820. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52821. * @param data contains the texture data
  52822. * @param texture defines the BabylonJS internal texture
  52823. * @param callback defines the method to call once ready to upload
  52824. */
  52825. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52826. }
  52827. }
  52828. declare module BABYLON {
  52829. /** @hidden */
  52830. export var _forceSceneHelpersToBundle: boolean;
  52831. interface Scene {
  52832. /**
  52833. * Creates a default light for the scene.
  52834. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52835. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52836. */
  52837. createDefaultLight(replace?: boolean): void;
  52838. /**
  52839. * Creates a default camera for the scene.
  52840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52841. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52842. * @param replace has default false, when true replaces the active camera in the scene
  52843. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52844. */
  52845. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52846. /**
  52847. * Creates a default camera and a default light.
  52848. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52849. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52850. * @param replace has the default false, when true replaces the active camera/light in the scene
  52851. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52852. */
  52853. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52854. /**
  52855. * Creates a new sky box
  52856. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52857. * @param environmentTexture defines the texture to use as environment texture
  52858. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52859. * @param scale defines the overall scale of the skybox
  52860. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52861. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52862. * @returns a new mesh holding the sky box
  52863. */
  52864. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52865. /**
  52866. * Creates a new environment
  52867. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52868. * @param options defines the options you can use to configure the environment
  52869. * @returns the new EnvironmentHelper
  52870. */
  52871. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52872. /**
  52873. * Creates a new VREXperienceHelper
  52874. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52875. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52876. * @returns a new VREXperienceHelper
  52877. */
  52878. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52879. /**
  52880. * Creates a new WebXRDefaultExperience
  52881. * @see http://doc.babylonjs.com/how_to/webxr
  52882. * @param options experience options
  52883. * @returns a promise for a new WebXRDefaultExperience
  52884. */
  52885. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52886. }
  52887. }
  52888. declare module BABYLON {
  52889. /**
  52890. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52891. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52892. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52893. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52894. */
  52895. export class VideoDome extends TransformNode {
  52896. /**
  52897. * Define the video source as a Monoscopic panoramic 360 video.
  52898. */
  52899. static readonly MODE_MONOSCOPIC: number;
  52900. /**
  52901. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52902. */
  52903. static readonly MODE_TOPBOTTOM: number;
  52904. /**
  52905. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52906. */
  52907. static readonly MODE_SIDEBYSIDE: number;
  52908. private _halfDome;
  52909. private _useDirectMapping;
  52910. /**
  52911. * The video texture being displayed on the sphere
  52912. */
  52913. protected _videoTexture: VideoTexture;
  52914. /**
  52915. * Gets the video texture being displayed on the sphere
  52916. */
  52917. get videoTexture(): VideoTexture;
  52918. /**
  52919. * The skybox material
  52920. */
  52921. protected _material: BackgroundMaterial;
  52922. /**
  52923. * The surface used for the skybox
  52924. */
  52925. protected _mesh: Mesh;
  52926. /**
  52927. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52928. */
  52929. private _halfDomeMask;
  52930. /**
  52931. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52932. * Also see the options.resolution property.
  52933. */
  52934. get fovMultiplier(): number;
  52935. set fovMultiplier(value: number);
  52936. private _videoMode;
  52937. /**
  52938. * Gets or set the current video mode for the video. It can be:
  52939. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52940. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52941. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52942. */
  52943. get videoMode(): number;
  52944. set videoMode(value: number);
  52945. /**
  52946. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52947. *
  52948. */
  52949. get halfDome(): boolean;
  52950. /**
  52951. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52952. */
  52953. set halfDome(enabled: boolean);
  52954. /**
  52955. * Oberserver used in Stereoscopic VR Mode.
  52956. */
  52957. private _onBeforeCameraRenderObserver;
  52958. /**
  52959. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52960. * @param name Element's name, child elements will append suffixes for their own names.
  52961. * @param urlsOrVideo defines the url(s) or the video element to use
  52962. * @param options An object containing optional or exposed sub element properties
  52963. */
  52964. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52965. resolution?: number;
  52966. clickToPlay?: boolean;
  52967. autoPlay?: boolean;
  52968. loop?: boolean;
  52969. size?: number;
  52970. poster?: string;
  52971. faceForward?: boolean;
  52972. useDirectMapping?: boolean;
  52973. halfDomeMode?: boolean;
  52974. }, scene: Scene);
  52975. private _changeVideoMode;
  52976. /**
  52977. * Releases resources associated with this node.
  52978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52980. */
  52981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52982. }
  52983. }
  52984. declare module BABYLON {
  52985. /**
  52986. * This class can be used to get instrumentation data from a Babylon engine
  52987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52988. */
  52989. export class EngineInstrumentation implements IDisposable {
  52990. /**
  52991. * Define the instrumented engine.
  52992. */
  52993. engine: Engine;
  52994. private _captureGPUFrameTime;
  52995. private _gpuFrameTimeToken;
  52996. private _gpuFrameTime;
  52997. private _captureShaderCompilationTime;
  52998. private _shaderCompilationTime;
  52999. private _onBeginFrameObserver;
  53000. private _onEndFrameObserver;
  53001. private _onBeforeShaderCompilationObserver;
  53002. private _onAfterShaderCompilationObserver;
  53003. /**
  53004. * Gets the perf counter used for GPU frame time
  53005. */
  53006. get gpuFrameTimeCounter(): PerfCounter;
  53007. /**
  53008. * Gets the GPU frame time capture status
  53009. */
  53010. get captureGPUFrameTime(): boolean;
  53011. /**
  53012. * Enable or disable the GPU frame time capture
  53013. */
  53014. set captureGPUFrameTime(value: boolean);
  53015. /**
  53016. * Gets the perf counter used for shader compilation time
  53017. */
  53018. get shaderCompilationTimeCounter(): PerfCounter;
  53019. /**
  53020. * Gets the shader compilation time capture status
  53021. */
  53022. get captureShaderCompilationTime(): boolean;
  53023. /**
  53024. * Enable or disable the shader compilation time capture
  53025. */
  53026. set captureShaderCompilationTime(value: boolean);
  53027. /**
  53028. * Instantiates a new engine instrumentation.
  53029. * This class can be used to get instrumentation data from a Babylon engine
  53030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53031. * @param engine Defines the engine to instrument
  53032. */
  53033. constructor(
  53034. /**
  53035. * Define the instrumented engine.
  53036. */
  53037. engine: Engine);
  53038. /**
  53039. * Dispose and release associated resources.
  53040. */
  53041. dispose(): void;
  53042. }
  53043. }
  53044. declare module BABYLON {
  53045. /**
  53046. * This class can be used to get instrumentation data from a Babylon engine
  53047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53048. */
  53049. export class SceneInstrumentation implements IDisposable {
  53050. /**
  53051. * Defines the scene to instrument
  53052. */
  53053. scene: Scene;
  53054. private _captureActiveMeshesEvaluationTime;
  53055. private _activeMeshesEvaluationTime;
  53056. private _captureRenderTargetsRenderTime;
  53057. private _renderTargetsRenderTime;
  53058. private _captureFrameTime;
  53059. private _frameTime;
  53060. private _captureRenderTime;
  53061. private _renderTime;
  53062. private _captureInterFrameTime;
  53063. private _interFrameTime;
  53064. private _captureParticlesRenderTime;
  53065. private _particlesRenderTime;
  53066. private _captureSpritesRenderTime;
  53067. private _spritesRenderTime;
  53068. private _capturePhysicsTime;
  53069. private _physicsTime;
  53070. private _captureAnimationsTime;
  53071. private _animationsTime;
  53072. private _captureCameraRenderTime;
  53073. private _cameraRenderTime;
  53074. private _onBeforeActiveMeshesEvaluationObserver;
  53075. private _onAfterActiveMeshesEvaluationObserver;
  53076. private _onBeforeRenderTargetsRenderObserver;
  53077. private _onAfterRenderTargetsRenderObserver;
  53078. private _onAfterRenderObserver;
  53079. private _onBeforeDrawPhaseObserver;
  53080. private _onAfterDrawPhaseObserver;
  53081. private _onBeforeAnimationsObserver;
  53082. private _onBeforeParticlesRenderingObserver;
  53083. private _onAfterParticlesRenderingObserver;
  53084. private _onBeforeSpritesRenderingObserver;
  53085. private _onAfterSpritesRenderingObserver;
  53086. private _onBeforePhysicsObserver;
  53087. private _onAfterPhysicsObserver;
  53088. private _onAfterAnimationsObserver;
  53089. private _onBeforeCameraRenderObserver;
  53090. private _onAfterCameraRenderObserver;
  53091. /**
  53092. * Gets the perf counter used for active meshes evaluation time
  53093. */
  53094. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53095. /**
  53096. * Gets the active meshes evaluation time capture status
  53097. */
  53098. get captureActiveMeshesEvaluationTime(): boolean;
  53099. /**
  53100. * Enable or disable the active meshes evaluation time capture
  53101. */
  53102. set captureActiveMeshesEvaluationTime(value: boolean);
  53103. /**
  53104. * Gets the perf counter used for render targets render time
  53105. */
  53106. get renderTargetsRenderTimeCounter(): PerfCounter;
  53107. /**
  53108. * Gets the render targets render time capture status
  53109. */
  53110. get captureRenderTargetsRenderTime(): boolean;
  53111. /**
  53112. * Enable or disable the render targets render time capture
  53113. */
  53114. set captureRenderTargetsRenderTime(value: boolean);
  53115. /**
  53116. * Gets the perf counter used for particles render time
  53117. */
  53118. get particlesRenderTimeCounter(): PerfCounter;
  53119. /**
  53120. * Gets the particles render time capture status
  53121. */
  53122. get captureParticlesRenderTime(): boolean;
  53123. /**
  53124. * Enable or disable the particles render time capture
  53125. */
  53126. set captureParticlesRenderTime(value: boolean);
  53127. /**
  53128. * Gets the perf counter used for sprites render time
  53129. */
  53130. get spritesRenderTimeCounter(): PerfCounter;
  53131. /**
  53132. * Gets the sprites render time capture status
  53133. */
  53134. get captureSpritesRenderTime(): boolean;
  53135. /**
  53136. * Enable or disable the sprites render time capture
  53137. */
  53138. set captureSpritesRenderTime(value: boolean);
  53139. /**
  53140. * Gets the perf counter used for physics time
  53141. */
  53142. get physicsTimeCounter(): PerfCounter;
  53143. /**
  53144. * Gets the physics time capture status
  53145. */
  53146. get capturePhysicsTime(): boolean;
  53147. /**
  53148. * Enable or disable the physics time capture
  53149. */
  53150. set capturePhysicsTime(value: boolean);
  53151. /**
  53152. * Gets the perf counter used for animations time
  53153. */
  53154. get animationsTimeCounter(): PerfCounter;
  53155. /**
  53156. * Gets the animations time capture status
  53157. */
  53158. get captureAnimationsTime(): boolean;
  53159. /**
  53160. * Enable or disable the animations time capture
  53161. */
  53162. set captureAnimationsTime(value: boolean);
  53163. /**
  53164. * Gets the perf counter used for frame time capture
  53165. */
  53166. get frameTimeCounter(): PerfCounter;
  53167. /**
  53168. * Gets the frame time capture status
  53169. */
  53170. get captureFrameTime(): boolean;
  53171. /**
  53172. * Enable or disable the frame time capture
  53173. */
  53174. set captureFrameTime(value: boolean);
  53175. /**
  53176. * Gets the perf counter used for inter-frames time capture
  53177. */
  53178. get interFrameTimeCounter(): PerfCounter;
  53179. /**
  53180. * Gets the inter-frames time capture status
  53181. */
  53182. get captureInterFrameTime(): boolean;
  53183. /**
  53184. * Enable or disable the inter-frames time capture
  53185. */
  53186. set captureInterFrameTime(value: boolean);
  53187. /**
  53188. * Gets the perf counter used for render time capture
  53189. */
  53190. get renderTimeCounter(): PerfCounter;
  53191. /**
  53192. * Gets the render time capture status
  53193. */
  53194. get captureRenderTime(): boolean;
  53195. /**
  53196. * Enable or disable the render time capture
  53197. */
  53198. set captureRenderTime(value: boolean);
  53199. /**
  53200. * Gets the perf counter used for camera render time capture
  53201. */
  53202. get cameraRenderTimeCounter(): PerfCounter;
  53203. /**
  53204. * Gets the camera render time capture status
  53205. */
  53206. get captureCameraRenderTime(): boolean;
  53207. /**
  53208. * Enable or disable the camera render time capture
  53209. */
  53210. set captureCameraRenderTime(value: boolean);
  53211. /**
  53212. * Gets the perf counter used for draw calls
  53213. */
  53214. get drawCallsCounter(): PerfCounter;
  53215. /**
  53216. * Instantiates a new scene instrumentation.
  53217. * This class can be used to get instrumentation data from a Babylon engine
  53218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53219. * @param scene Defines the scene to instrument
  53220. */
  53221. constructor(
  53222. /**
  53223. * Defines the scene to instrument
  53224. */
  53225. scene: Scene);
  53226. /**
  53227. * Dispose and release associated resources.
  53228. */
  53229. dispose(): void;
  53230. }
  53231. }
  53232. declare module BABYLON {
  53233. /** @hidden */
  53234. export var glowMapGenerationPixelShader: {
  53235. name: string;
  53236. shader: string;
  53237. };
  53238. }
  53239. declare module BABYLON {
  53240. /** @hidden */
  53241. export var glowMapGenerationVertexShader: {
  53242. name: string;
  53243. shader: string;
  53244. };
  53245. }
  53246. declare module BABYLON {
  53247. /**
  53248. * Effect layer options. This helps customizing the behaviour
  53249. * of the effect layer.
  53250. */
  53251. export interface IEffectLayerOptions {
  53252. /**
  53253. * Multiplication factor apply to the canvas size to compute the render target size
  53254. * used to generated the objects (the smaller the faster).
  53255. */
  53256. mainTextureRatio: number;
  53257. /**
  53258. * Enforces a fixed size texture to ensure effect stability across devices.
  53259. */
  53260. mainTextureFixedSize?: number;
  53261. /**
  53262. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53263. */
  53264. alphaBlendingMode: number;
  53265. /**
  53266. * The camera attached to the layer.
  53267. */
  53268. camera: Nullable<Camera>;
  53269. /**
  53270. * The rendering group to draw the layer in.
  53271. */
  53272. renderingGroupId: number;
  53273. }
  53274. /**
  53275. * The effect layer Helps adding post process effect blended with the main pass.
  53276. *
  53277. * This can be for instance use to generate glow or higlight effects on the scene.
  53278. *
  53279. * The effect layer class can not be used directly and is intented to inherited from to be
  53280. * customized per effects.
  53281. */
  53282. export abstract class EffectLayer {
  53283. private _vertexBuffers;
  53284. private _indexBuffer;
  53285. private _cachedDefines;
  53286. private _effectLayerMapGenerationEffect;
  53287. private _effectLayerOptions;
  53288. private _mergeEffect;
  53289. protected _scene: Scene;
  53290. protected _engine: Engine;
  53291. protected _maxSize: number;
  53292. protected _mainTextureDesiredSize: ISize;
  53293. protected _mainTexture: RenderTargetTexture;
  53294. protected _shouldRender: boolean;
  53295. protected _postProcesses: PostProcess[];
  53296. protected _textures: BaseTexture[];
  53297. protected _emissiveTextureAndColor: {
  53298. texture: Nullable<BaseTexture>;
  53299. color: Color4;
  53300. };
  53301. /**
  53302. * The name of the layer
  53303. */
  53304. name: string;
  53305. /**
  53306. * The clear color of the texture used to generate the glow map.
  53307. */
  53308. neutralColor: Color4;
  53309. /**
  53310. * Specifies whether the highlight layer is enabled or not.
  53311. */
  53312. isEnabled: boolean;
  53313. /**
  53314. * Gets the camera attached to the layer.
  53315. */
  53316. get camera(): Nullable<Camera>;
  53317. /**
  53318. * Gets the rendering group id the layer should render in.
  53319. */
  53320. get renderingGroupId(): number;
  53321. set renderingGroupId(renderingGroupId: number);
  53322. /**
  53323. * An event triggered when the effect layer has been disposed.
  53324. */
  53325. onDisposeObservable: Observable<EffectLayer>;
  53326. /**
  53327. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53328. */
  53329. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53330. /**
  53331. * An event triggered when the generated texture is being merged in the scene.
  53332. */
  53333. onBeforeComposeObservable: Observable<EffectLayer>;
  53334. /**
  53335. * An event triggered when the mesh is rendered into the effect render target.
  53336. */
  53337. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53338. /**
  53339. * An event triggered after the mesh has been rendered into the effect render target.
  53340. */
  53341. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53342. /**
  53343. * An event triggered when the generated texture has been merged in the scene.
  53344. */
  53345. onAfterComposeObservable: Observable<EffectLayer>;
  53346. /**
  53347. * An event triggered when the efffect layer changes its size.
  53348. */
  53349. onSizeChangedObservable: Observable<EffectLayer>;
  53350. /** @hidden */
  53351. static _SceneComponentInitialization: (scene: Scene) => void;
  53352. /**
  53353. * Instantiates a new effect Layer and references it in the scene.
  53354. * @param name The name of the layer
  53355. * @param scene The scene to use the layer in
  53356. */
  53357. constructor(
  53358. /** The Friendly of the effect in the scene */
  53359. name: string, scene: Scene);
  53360. /**
  53361. * Get the effect name of the layer.
  53362. * @return The effect name
  53363. */
  53364. abstract getEffectName(): string;
  53365. /**
  53366. * Checks for the readiness of the element composing the layer.
  53367. * @param subMesh the mesh to check for
  53368. * @param useInstances specify whether or not to use instances to render the mesh
  53369. * @return true if ready otherwise, false
  53370. */
  53371. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53372. /**
  53373. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53374. * @returns true if the effect requires stencil during the main canvas render pass.
  53375. */
  53376. abstract needStencil(): boolean;
  53377. /**
  53378. * Create the merge effect. This is the shader use to blit the information back
  53379. * to the main canvas at the end of the scene rendering.
  53380. * @returns The effect containing the shader used to merge the effect on the main canvas
  53381. */
  53382. protected abstract _createMergeEffect(): Effect;
  53383. /**
  53384. * Creates the render target textures and post processes used in the effect layer.
  53385. */
  53386. protected abstract _createTextureAndPostProcesses(): void;
  53387. /**
  53388. * Implementation specific of rendering the generating effect on the main canvas.
  53389. * @param effect The effect used to render through
  53390. */
  53391. protected abstract _internalRender(effect: Effect): void;
  53392. /**
  53393. * Sets the required values for both the emissive texture and and the main color.
  53394. */
  53395. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53396. /**
  53397. * Free any resources and references associated to a mesh.
  53398. * Internal use
  53399. * @param mesh The mesh to free.
  53400. */
  53401. abstract _disposeMesh(mesh: Mesh): void;
  53402. /**
  53403. * Serializes this layer (Glow or Highlight for example)
  53404. * @returns a serialized layer object
  53405. */
  53406. abstract serialize?(): any;
  53407. /**
  53408. * Initializes the effect layer with the required options.
  53409. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53410. */
  53411. protected _init(options: Partial<IEffectLayerOptions>): void;
  53412. /**
  53413. * Generates the index buffer of the full screen quad blending to the main canvas.
  53414. */
  53415. private _generateIndexBuffer;
  53416. /**
  53417. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53418. */
  53419. private _generateVertexBuffer;
  53420. /**
  53421. * Sets the main texture desired size which is the closest power of two
  53422. * of the engine canvas size.
  53423. */
  53424. private _setMainTextureSize;
  53425. /**
  53426. * Creates the main texture for the effect layer.
  53427. */
  53428. protected _createMainTexture(): void;
  53429. /**
  53430. * Adds specific effects defines.
  53431. * @param defines The defines to add specifics to.
  53432. */
  53433. protected _addCustomEffectDefines(defines: string[]): void;
  53434. /**
  53435. * Checks for the readiness of the element composing the layer.
  53436. * @param subMesh the mesh to check for
  53437. * @param useInstances specify whether or not to use instances to render the mesh
  53438. * @param emissiveTexture the associated emissive texture used to generate the glow
  53439. * @return true if ready otherwise, false
  53440. */
  53441. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53442. /**
  53443. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53444. */
  53445. render(): void;
  53446. /**
  53447. * Determine if a given mesh will be used in the current effect.
  53448. * @param mesh mesh to test
  53449. * @returns true if the mesh will be used
  53450. */
  53451. hasMesh(mesh: AbstractMesh): boolean;
  53452. /**
  53453. * Returns true if the layer contains information to display, otherwise false.
  53454. * @returns true if the glow layer should be rendered
  53455. */
  53456. shouldRender(): boolean;
  53457. /**
  53458. * Returns true if the mesh should render, otherwise false.
  53459. * @param mesh The mesh to render
  53460. * @returns true if it should render otherwise false
  53461. */
  53462. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53463. /**
  53464. * Returns true if the mesh can be rendered, otherwise false.
  53465. * @param mesh The mesh to render
  53466. * @param material The material used on the mesh
  53467. * @returns true if it can be rendered otherwise false
  53468. */
  53469. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53470. /**
  53471. * Returns true if the mesh should render, otherwise false.
  53472. * @param mesh The mesh to render
  53473. * @returns true if it should render otherwise false
  53474. */
  53475. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53476. /**
  53477. * Renders the submesh passed in parameter to the generation map.
  53478. */
  53479. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53480. /**
  53481. * Defines whether the current material of the mesh should be use to render the effect.
  53482. * @param mesh defines the current mesh to render
  53483. */
  53484. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53485. /**
  53486. * Rebuild the required buffers.
  53487. * @hidden Internal use only.
  53488. */
  53489. _rebuild(): void;
  53490. /**
  53491. * Dispose only the render target textures and post process.
  53492. */
  53493. private _disposeTextureAndPostProcesses;
  53494. /**
  53495. * Dispose the highlight layer and free resources.
  53496. */
  53497. dispose(): void;
  53498. /**
  53499. * Gets the class name of the effect layer
  53500. * @returns the string with the class name of the effect layer
  53501. */
  53502. getClassName(): string;
  53503. /**
  53504. * Creates an effect layer from parsed effect layer data
  53505. * @param parsedEffectLayer defines effect layer data
  53506. * @param scene defines the current scene
  53507. * @param rootUrl defines the root URL containing the effect layer information
  53508. * @returns a parsed effect Layer
  53509. */
  53510. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53511. }
  53512. }
  53513. declare module BABYLON {
  53514. interface AbstractScene {
  53515. /**
  53516. * The list of effect layers (highlights/glow) added to the scene
  53517. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53518. * @see http://doc.babylonjs.com/how_to/glow_layer
  53519. */
  53520. effectLayers: Array<EffectLayer>;
  53521. /**
  53522. * Removes the given effect layer from this scene.
  53523. * @param toRemove defines the effect layer to remove
  53524. * @returns the index of the removed effect layer
  53525. */
  53526. removeEffectLayer(toRemove: EffectLayer): number;
  53527. /**
  53528. * Adds the given effect layer to this scene
  53529. * @param newEffectLayer defines the effect layer to add
  53530. */
  53531. addEffectLayer(newEffectLayer: EffectLayer): void;
  53532. }
  53533. /**
  53534. * Defines the layer scene component responsible to manage any effect layers
  53535. * in a given scene.
  53536. */
  53537. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53538. /**
  53539. * The component name helpfull to identify the component in the list of scene components.
  53540. */
  53541. readonly name: string;
  53542. /**
  53543. * The scene the component belongs to.
  53544. */
  53545. scene: Scene;
  53546. private _engine;
  53547. private _renderEffects;
  53548. private _needStencil;
  53549. private _previousStencilState;
  53550. /**
  53551. * Creates a new instance of the component for the given scene
  53552. * @param scene Defines the scene to register the component in
  53553. */
  53554. constructor(scene: Scene);
  53555. /**
  53556. * Registers the component in a given scene
  53557. */
  53558. register(): void;
  53559. /**
  53560. * Rebuilds the elements related to this component in case of
  53561. * context lost for instance.
  53562. */
  53563. rebuild(): void;
  53564. /**
  53565. * Serializes the component data to the specified json object
  53566. * @param serializationObject The object to serialize to
  53567. */
  53568. serialize(serializationObject: any): void;
  53569. /**
  53570. * Adds all the elements from the container to the scene
  53571. * @param container the container holding the elements
  53572. */
  53573. addFromContainer(container: AbstractScene): void;
  53574. /**
  53575. * Removes all the elements in the container from the scene
  53576. * @param container contains the elements to remove
  53577. * @param dispose if the removed element should be disposed (default: false)
  53578. */
  53579. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53580. /**
  53581. * Disposes the component and the associated ressources.
  53582. */
  53583. dispose(): void;
  53584. private _isReadyForMesh;
  53585. private _renderMainTexture;
  53586. private _setStencil;
  53587. private _setStencilBack;
  53588. private _draw;
  53589. private _drawCamera;
  53590. private _drawRenderingGroup;
  53591. }
  53592. }
  53593. declare module BABYLON {
  53594. /** @hidden */
  53595. export var glowMapMergePixelShader: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module BABYLON {
  53601. /** @hidden */
  53602. export var glowMapMergeVertexShader: {
  53603. name: string;
  53604. shader: string;
  53605. };
  53606. }
  53607. declare module BABYLON {
  53608. interface AbstractScene {
  53609. /**
  53610. * Return a the first highlight layer of the scene with a given name.
  53611. * @param name The name of the highlight layer to look for.
  53612. * @return The highlight layer if found otherwise null.
  53613. */
  53614. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53615. }
  53616. /**
  53617. * Glow layer options. This helps customizing the behaviour
  53618. * of the glow layer.
  53619. */
  53620. export interface IGlowLayerOptions {
  53621. /**
  53622. * Multiplication factor apply to the canvas size to compute the render target size
  53623. * used to generated the glowing objects (the smaller the faster).
  53624. */
  53625. mainTextureRatio: number;
  53626. /**
  53627. * Enforces a fixed size texture to ensure resize independant blur.
  53628. */
  53629. mainTextureFixedSize?: number;
  53630. /**
  53631. * How big is the kernel of the blur texture.
  53632. */
  53633. blurKernelSize: number;
  53634. /**
  53635. * The camera attached to the layer.
  53636. */
  53637. camera: Nullable<Camera>;
  53638. /**
  53639. * Enable MSAA by chosing the number of samples.
  53640. */
  53641. mainTextureSamples?: number;
  53642. /**
  53643. * The rendering group to draw the layer in.
  53644. */
  53645. renderingGroupId: number;
  53646. }
  53647. /**
  53648. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53649. *
  53650. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53651. *
  53652. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53653. */
  53654. export class GlowLayer extends EffectLayer {
  53655. /**
  53656. * Effect Name of the layer.
  53657. */
  53658. static readonly EffectName: string;
  53659. /**
  53660. * The default blur kernel size used for the glow.
  53661. */
  53662. static DefaultBlurKernelSize: number;
  53663. /**
  53664. * The default texture size ratio used for the glow.
  53665. */
  53666. static DefaultTextureRatio: number;
  53667. /**
  53668. * Sets the kernel size of the blur.
  53669. */
  53670. set blurKernelSize(value: number);
  53671. /**
  53672. * Gets the kernel size of the blur.
  53673. */
  53674. get blurKernelSize(): number;
  53675. /**
  53676. * Sets the glow intensity.
  53677. */
  53678. set intensity(value: number);
  53679. /**
  53680. * Gets the glow intensity.
  53681. */
  53682. get intensity(): number;
  53683. private _options;
  53684. private _intensity;
  53685. private _horizontalBlurPostprocess1;
  53686. private _verticalBlurPostprocess1;
  53687. private _horizontalBlurPostprocess2;
  53688. private _verticalBlurPostprocess2;
  53689. private _blurTexture1;
  53690. private _blurTexture2;
  53691. private _postProcesses1;
  53692. private _postProcesses2;
  53693. private _includedOnlyMeshes;
  53694. private _excludedMeshes;
  53695. private _meshesUsingTheirOwnMaterials;
  53696. /**
  53697. * Callback used to let the user override the color selection on a per mesh basis
  53698. */
  53699. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53700. /**
  53701. * Callback used to let the user override the texture selection on a per mesh basis
  53702. */
  53703. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53704. /**
  53705. * Instantiates a new glow Layer and references it to the scene.
  53706. * @param name The name of the layer
  53707. * @param scene The scene to use the layer in
  53708. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53709. */
  53710. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53711. /**
  53712. * Get the effect name of the layer.
  53713. * @return The effect name
  53714. */
  53715. getEffectName(): string;
  53716. /**
  53717. * Create the merge effect. This is the shader use to blit the information back
  53718. * to the main canvas at the end of the scene rendering.
  53719. */
  53720. protected _createMergeEffect(): Effect;
  53721. /**
  53722. * Creates the render target textures and post processes used in the glow layer.
  53723. */
  53724. protected _createTextureAndPostProcesses(): void;
  53725. /**
  53726. * Checks for the readiness of the element composing the layer.
  53727. * @param subMesh the mesh to check for
  53728. * @param useInstances specify wether or not to use instances to render the mesh
  53729. * @param emissiveTexture the associated emissive texture used to generate the glow
  53730. * @return true if ready otherwise, false
  53731. */
  53732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53733. /**
  53734. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53735. */
  53736. needStencil(): boolean;
  53737. /**
  53738. * Returns true if the mesh can be rendered, otherwise false.
  53739. * @param mesh The mesh to render
  53740. * @param material The material used on the mesh
  53741. * @returns true if it can be rendered otherwise false
  53742. */
  53743. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53744. /**
  53745. * Implementation specific of rendering the generating effect on the main canvas.
  53746. * @param effect The effect used to render through
  53747. */
  53748. protected _internalRender(effect: Effect): void;
  53749. /**
  53750. * Sets the required values for both the emissive texture and and the main color.
  53751. */
  53752. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53753. /**
  53754. * Returns true if the mesh should render, otherwise false.
  53755. * @param mesh The mesh to render
  53756. * @returns true if it should render otherwise false
  53757. */
  53758. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53759. /**
  53760. * Adds specific effects defines.
  53761. * @param defines The defines to add specifics to.
  53762. */
  53763. protected _addCustomEffectDefines(defines: string[]): void;
  53764. /**
  53765. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53766. * @param mesh The mesh to exclude from the glow layer
  53767. */
  53768. addExcludedMesh(mesh: Mesh): void;
  53769. /**
  53770. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53771. * @param mesh The mesh to remove
  53772. */
  53773. removeExcludedMesh(mesh: Mesh): void;
  53774. /**
  53775. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53776. * @param mesh The mesh to include in the glow layer
  53777. */
  53778. addIncludedOnlyMesh(mesh: Mesh): void;
  53779. /**
  53780. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53781. * @param mesh The mesh to remove
  53782. */
  53783. removeIncludedOnlyMesh(mesh: Mesh): void;
  53784. /**
  53785. * Determine if a given mesh will be used in the glow layer
  53786. * @param mesh The mesh to test
  53787. * @returns true if the mesh will be highlighted by the current glow layer
  53788. */
  53789. hasMesh(mesh: AbstractMesh): boolean;
  53790. /**
  53791. * Defines whether the current material of the mesh should be use to render the effect.
  53792. * @param mesh defines the current mesh to render
  53793. */
  53794. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53795. /**
  53796. * Add a mesh to be rendered through its own material and not with emissive only.
  53797. * @param mesh The mesh for which we need to use its material
  53798. */
  53799. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53800. /**
  53801. * Remove a mesh from being rendered through its own material and not with emissive only.
  53802. * @param mesh The mesh for which we need to not use its material
  53803. */
  53804. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53805. /**
  53806. * Free any resources and references associated to a mesh.
  53807. * Internal use
  53808. * @param mesh The mesh to free.
  53809. * @hidden
  53810. */
  53811. _disposeMesh(mesh: Mesh): void;
  53812. /**
  53813. * Gets the class name of the effect layer
  53814. * @returns the string with the class name of the effect layer
  53815. */
  53816. getClassName(): string;
  53817. /**
  53818. * Serializes this glow layer
  53819. * @returns a serialized glow layer object
  53820. */
  53821. serialize(): any;
  53822. /**
  53823. * Creates a Glow Layer from parsed glow layer data
  53824. * @param parsedGlowLayer defines glow layer data
  53825. * @param scene defines the current scene
  53826. * @param rootUrl defines the root URL containing the glow layer information
  53827. * @returns a parsed Glow Layer
  53828. */
  53829. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. /** @hidden */
  53834. export var glowBlurPostProcessPixelShader: {
  53835. name: string;
  53836. shader: string;
  53837. };
  53838. }
  53839. declare module BABYLON {
  53840. interface AbstractScene {
  53841. /**
  53842. * Return a the first highlight layer of the scene with a given name.
  53843. * @param name The name of the highlight layer to look for.
  53844. * @return The highlight layer if found otherwise null.
  53845. */
  53846. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53847. }
  53848. /**
  53849. * Highlight layer options. This helps customizing the behaviour
  53850. * of the highlight layer.
  53851. */
  53852. export interface IHighlightLayerOptions {
  53853. /**
  53854. * Multiplication factor apply to the canvas size to compute the render target size
  53855. * used to generated the glowing objects (the smaller the faster).
  53856. */
  53857. mainTextureRatio: number;
  53858. /**
  53859. * Enforces a fixed size texture to ensure resize independant blur.
  53860. */
  53861. mainTextureFixedSize?: number;
  53862. /**
  53863. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53864. * of the picture to blur (the smaller the faster).
  53865. */
  53866. blurTextureSizeRatio: number;
  53867. /**
  53868. * How big in texel of the blur texture is the vertical blur.
  53869. */
  53870. blurVerticalSize: number;
  53871. /**
  53872. * How big in texel of the blur texture is the horizontal blur.
  53873. */
  53874. blurHorizontalSize: number;
  53875. /**
  53876. * Alpha blending mode used to apply the blur. Default is combine.
  53877. */
  53878. alphaBlendingMode: number;
  53879. /**
  53880. * The camera attached to the layer.
  53881. */
  53882. camera: Nullable<Camera>;
  53883. /**
  53884. * Should we display highlight as a solid stroke?
  53885. */
  53886. isStroke?: boolean;
  53887. /**
  53888. * The rendering group to draw the layer in.
  53889. */
  53890. renderingGroupId: number;
  53891. }
  53892. /**
  53893. * The highlight layer Helps adding a glow effect around a mesh.
  53894. *
  53895. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53896. * glowy meshes to your scene.
  53897. *
  53898. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53899. */
  53900. export class HighlightLayer extends EffectLayer {
  53901. name: string;
  53902. /**
  53903. * Effect Name of the highlight layer.
  53904. */
  53905. static readonly EffectName: string;
  53906. /**
  53907. * The neutral color used during the preparation of the glow effect.
  53908. * This is black by default as the blend operation is a blend operation.
  53909. */
  53910. static NeutralColor: Color4;
  53911. /**
  53912. * Stencil value used for glowing meshes.
  53913. */
  53914. static GlowingMeshStencilReference: number;
  53915. /**
  53916. * Stencil value used for the other meshes in the scene.
  53917. */
  53918. static NormalMeshStencilReference: number;
  53919. /**
  53920. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53921. */
  53922. innerGlow: boolean;
  53923. /**
  53924. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53925. */
  53926. outerGlow: boolean;
  53927. /**
  53928. * Specifies the horizontal size of the blur.
  53929. */
  53930. set blurHorizontalSize(value: number);
  53931. /**
  53932. * Specifies the vertical size of the blur.
  53933. */
  53934. set blurVerticalSize(value: number);
  53935. /**
  53936. * Gets the horizontal size of the blur.
  53937. */
  53938. get blurHorizontalSize(): number;
  53939. /**
  53940. * Gets the vertical size of the blur.
  53941. */
  53942. get blurVerticalSize(): number;
  53943. /**
  53944. * An event triggered when the highlight layer is being blurred.
  53945. */
  53946. onBeforeBlurObservable: Observable<HighlightLayer>;
  53947. /**
  53948. * An event triggered when the highlight layer has been blurred.
  53949. */
  53950. onAfterBlurObservable: Observable<HighlightLayer>;
  53951. private _instanceGlowingMeshStencilReference;
  53952. private _options;
  53953. private _downSamplePostprocess;
  53954. private _horizontalBlurPostprocess;
  53955. private _verticalBlurPostprocess;
  53956. private _blurTexture;
  53957. private _meshes;
  53958. private _excludedMeshes;
  53959. /**
  53960. * Instantiates a new highlight Layer and references it to the scene..
  53961. * @param name The name of the layer
  53962. * @param scene The scene to use the layer in
  53963. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53964. */
  53965. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53966. /**
  53967. * Get the effect name of the layer.
  53968. * @return The effect name
  53969. */
  53970. getEffectName(): string;
  53971. /**
  53972. * Create the merge effect. This is the shader use to blit the information back
  53973. * to the main canvas at the end of the scene rendering.
  53974. */
  53975. protected _createMergeEffect(): Effect;
  53976. /**
  53977. * Creates the render target textures and post processes used in the highlight layer.
  53978. */
  53979. protected _createTextureAndPostProcesses(): void;
  53980. /**
  53981. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53982. */
  53983. needStencil(): boolean;
  53984. /**
  53985. * Checks for the readiness of the element composing the layer.
  53986. * @param subMesh the mesh to check for
  53987. * @param useInstances specify wether or not to use instances to render the mesh
  53988. * @param emissiveTexture the associated emissive texture used to generate the glow
  53989. * @return true if ready otherwise, false
  53990. */
  53991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53992. /**
  53993. * Implementation specific of rendering the generating effect on the main canvas.
  53994. * @param effect The effect used to render through
  53995. */
  53996. protected _internalRender(effect: Effect): void;
  53997. /**
  53998. * Returns true if the layer contains information to display, otherwise false.
  53999. */
  54000. shouldRender(): boolean;
  54001. /**
  54002. * Returns true if the mesh should render, otherwise false.
  54003. * @param mesh The mesh to render
  54004. * @returns true if it should render otherwise false
  54005. */
  54006. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54007. /**
  54008. * Adds specific effects defines.
  54009. * @param defines The defines to add specifics to.
  54010. */
  54011. protected _addCustomEffectDefines(defines: string[]): void;
  54012. /**
  54013. * Sets the required values for both the emissive texture and and the main color.
  54014. */
  54015. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54016. /**
  54017. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54018. * @param mesh The mesh to exclude from the highlight layer
  54019. */
  54020. addExcludedMesh(mesh: Mesh): void;
  54021. /**
  54022. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54023. * @param mesh The mesh to highlight
  54024. */
  54025. removeExcludedMesh(mesh: Mesh): void;
  54026. /**
  54027. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54028. * @param mesh mesh to test
  54029. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54030. */
  54031. hasMesh(mesh: AbstractMesh): boolean;
  54032. /**
  54033. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54034. * @param mesh The mesh to highlight
  54035. * @param color The color of the highlight
  54036. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54037. */
  54038. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54039. /**
  54040. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54041. * @param mesh The mesh to highlight
  54042. */
  54043. removeMesh(mesh: Mesh): void;
  54044. /**
  54045. * Remove all the meshes currently referenced in the highlight layer
  54046. */
  54047. removeAllMeshes(): void;
  54048. /**
  54049. * Force the stencil to the normal expected value for none glowing parts
  54050. */
  54051. private _defaultStencilReference;
  54052. /**
  54053. * Free any resources and references associated to a mesh.
  54054. * Internal use
  54055. * @param mesh The mesh to free.
  54056. * @hidden
  54057. */
  54058. _disposeMesh(mesh: Mesh): void;
  54059. /**
  54060. * Dispose the highlight layer and free resources.
  54061. */
  54062. dispose(): void;
  54063. /**
  54064. * Gets the class name of the effect layer
  54065. * @returns the string with the class name of the effect layer
  54066. */
  54067. getClassName(): string;
  54068. /**
  54069. * Serializes this Highlight layer
  54070. * @returns a serialized Highlight layer object
  54071. */
  54072. serialize(): any;
  54073. /**
  54074. * Creates a Highlight layer from parsed Highlight layer data
  54075. * @param parsedHightlightLayer defines the Highlight layer data
  54076. * @param scene defines the current scene
  54077. * @param rootUrl defines the root URL containing the Highlight layer information
  54078. * @returns a parsed Highlight layer
  54079. */
  54080. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54081. }
  54082. }
  54083. declare module BABYLON {
  54084. interface AbstractScene {
  54085. /**
  54086. * The list of layers (background and foreground) of the scene
  54087. */
  54088. layers: Array<Layer>;
  54089. }
  54090. /**
  54091. * Defines the layer scene component responsible to manage any layers
  54092. * in a given scene.
  54093. */
  54094. export class LayerSceneComponent implements ISceneComponent {
  54095. /**
  54096. * The component name helpfull to identify the component in the list of scene components.
  54097. */
  54098. readonly name: string;
  54099. /**
  54100. * The scene the component belongs to.
  54101. */
  54102. scene: Scene;
  54103. private _engine;
  54104. /**
  54105. * Creates a new instance of the component for the given scene
  54106. * @param scene Defines the scene to register the component in
  54107. */
  54108. constructor(scene: Scene);
  54109. /**
  54110. * Registers the component in a given scene
  54111. */
  54112. register(): void;
  54113. /**
  54114. * Rebuilds the elements related to this component in case of
  54115. * context lost for instance.
  54116. */
  54117. rebuild(): void;
  54118. /**
  54119. * Disposes the component and the associated ressources.
  54120. */
  54121. dispose(): void;
  54122. private _draw;
  54123. private _drawCameraPredicate;
  54124. private _drawCameraBackground;
  54125. private _drawCameraForeground;
  54126. private _drawRenderTargetPredicate;
  54127. private _drawRenderTargetBackground;
  54128. private _drawRenderTargetForeground;
  54129. /**
  54130. * Adds all the elements from the container to the scene
  54131. * @param container the container holding the elements
  54132. */
  54133. addFromContainer(container: AbstractScene): void;
  54134. /**
  54135. * Removes all the elements in the container from the scene
  54136. * @param container contains the elements to remove
  54137. * @param dispose if the removed element should be disposed (default: false)
  54138. */
  54139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54140. }
  54141. }
  54142. declare module BABYLON {
  54143. /** @hidden */
  54144. export var layerPixelShader: {
  54145. name: string;
  54146. shader: string;
  54147. };
  54148. }
  54149. declare module BABYLON {
  54150. /** @hidden */
  54151. export var layerVertexShader: {
  54152. name: string;
  54153. shader: string;
  54154. };
  54155. }
  54156. declare module BABYLON {
  54157. /**
  54158. * This represents a full screen 2d layer.
  54159. * This can be useful to display a picture in the background of your scene for instance.
  54160. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54161. */
  54162. export class Layer {
  54163. /**
  54164. * Define the name of the layer.
  54165. */
  54166. name: string;
  54167. /**
  54168. * Define the texture the layer should display.
  54169. */
  54170. texture: Nullable<Texture>;
  54171. /**
  54172. * Is the layer in background or foreground.
  54173. */
  54174. isBackground: boolean;
  54175. /**
  54176. * Define the color of the layer (instead of texture).
  54177. */
  54178. color: Color4;
  54179. /**
  54180. * Define the scale of the layer in order to zoom in out of the texture.
  54181. */
  54182. scale: Vector2;
  54183. /**
  54184. * Define an offset for the layer in order to shift the texture.
  54185. */
  54186. offset: Vector2;
  54187. /**
  54188. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54189. */
  54190. alphaBlendingMode: number;
  54191. /**
  54192. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54193. * Alpha test will not mix with the background color in case of transparency.
  54194. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54195. */
  54196. alphaTest: boolean;
  54197. /**
  54198. * Define a mask to restrict the layer to only some of the scene cameras.
  54199. */
  54200. layerMask: number;
  54201. /**
  54202. * Define the list of render target the layer is visible into.
  54203. */
  54204. renderTargetTextures: RenderTargetTexture[];
  54205. /**
  54206. * Define if the layer is only used in renderTarget or if it also
  54207. * renders in the main frame buffer of the canvas.
  54208. */
  54209. renderOnlyInRenderTargetTextures: boolean;
  54210. private _scene;
  54211. private _vertexBuffers;
  54212. private _indexBuffer;
  54213. private _effect;
  54214. private _previousDefines;
  54215. /**
  54216. * An event triggered when the layer is disposed.
  54217. */
  54218. onDisposeObservable: Observable<Layer>;
  54219. private _onDisposeObserver;
  54220. /**
  54221. * Back compatibility with callback before the onDisposeObservable existed.
  54222. * The set callback will be triggered when the layer has been disposed.
  54223. */
  54224. set onDispose(callback: () => void);
  54225. /**
  54226. * An event triggered before rendering the scene
  54227. */
  54228. onBeforeRenderObservable: Observable<Layer>;
  54229. private _onBeforeRenderObserver;
  54230. /**
  54231. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54232. * The set callback will be triggered just before rendering the layer.
  54233. */
  54234. set onBeforeRender(callback: () => void);
  54235. /**
  54236. * An event triggered after rendering the scene
  54237. */
  54238. onAfterRenderObservable: Observable<Layer>;
  54239. private _onAfterRenderObserver;
  54240. /**
  54241. * Back compatibility with callback before the onAfterRenderObservable existed.
  54242. * The set callback will be triggered just after rendering the layer.
  54243. */
  54244. set onAfterRender(callback: () => void);
  54245. /**
  54246. * Instantiates a new layer.
  54247. * This represents a full screen 2d layer.
  54248. * This can be useful to display a picture in the background of your scene for instance.
  54249. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54250. * @param name Define the name of the layer in the scene
  54251. * @param imgUrl Define the url of the texture to display in the layer
  54252. * @param scene Define the scene the layer belongs to
  54253. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54254. * @param color Defines a color for the layer
  54255. */
  54256. constructor(
  54257. /**
  54258. * Define the name of the layer.
  54259. */
  54260. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54261. private _createIndexBuffer;
  54262. /** @hidden */
  54263. _rebuild(): void;
  54264. /**
  54265. * Renders the layer in the scene.
  54266. */
  54267. render(): void;
  54268. /**
  54269. * Disposes and releases the associated ressources.
  54270. */
  54271. dispose(): void;
  54272. }
  54273. }
  54274. declare module BABYLON {
  54275. /** @hidden */
  54276. export var lensFlarePixelShader: {
  54277. name: string;
  54278. shader: string;
  54279. };
  54280. }
  54281. declare module BABYLON {
  54282. /** @hidden */
  54283. export var lensFlareVertexShader: {
  54284. name: string;
  54285. shader: string;
  54286. };
  54287. }
  54288. declare module BABYLON {
  54289. /**
  54290. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54291. * It is usually composed of several `lensFlare`.
  54292. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54293. */
  54294. export class LensFlareSystem {
  54295. /**
  54296. * Define the name of the lens flare system
  54297. */
  54298. name: string;
  54299. /**
  54300. * List of lens flares used in this system.
  54301. */
  54302. lensFlares: LensFlare[];
  54303. /**
  54304. * Define a limit from the border the lens flare can be visible.
  54305. */
  54306. borderLimit: number;
  54307. /**
  54308. * Define a viewport border we do not want to see the lens flare in.
  54309. */
  54310. viewportBorder: number;
  54311. /**
  54312. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54313. */
  54314. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54315. /**
  54316. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54317. */
  54318. layerMask: number;
  54319. /**
  54320. * Define the id of the lens flare system in the scene.
  54321. * (equal to name by default)
  54322. */
  54323. id: string;
  54324. private _scene;
  54325. private _emitter;
  54326. private _vertexBuffers;
  54327. private _indexBuffer;
  54328. private _effect;
  54329. private _positionX;
  54330. private _positionY;
  54331. private _isEnabled;
  54332. /** @hidden */
  54333. static _SceneComponentInitialization: (scene: Scene) => void;
  54334. /**
  54335. * Instantiates a lens flare system.
  54336. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54337. * It is usually composed of several `lensFlare`.
  54338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54339. * @param name Define the name of the lens flare system in the scene
  54340. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54341. * @param scene Define the scene the lens flare system belongs to
  54342. */
  54343. constructor(
  54344. /**
  54345. * Define the name of the lens flare system
  54346. */
  54347. name: string, emitter: any, scene: Scene);
  54348. /**
  54349. * Define if the lens flare system is enabled.
  54350. */
  54351. get isEnabled(): boolean;
  54352. set isEnabled(value: boolean);
  54353. /**
  54354. * Get the scene the effects belongs to.
  54355. * @returns the scene holding the lens flare system
  54356. */
  54357. getScene(): Scene;
  54358. /**
  54359. * Get the emitter of the lens flare system.
  54360. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54361. * @returns the emitter of the lens flare system
  54362. */
  54363. getEmitter(): any;
  54364. /**
  54365. * Set the emitter of the lens flare system.
  54366. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54367. * @param newEmitter Define the new emitter of the system
  54368. */
  54369. setEmitter(newEmitter: any): void;
  54370. /**
  54371. * Get the lens flare system emitter position.
  54372. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54373. * @returns the position
  54374. */
  54375. getEmitterPosition(): Vector3;
  54376. /**
  54377. * @hidden
  54378. */
  54379. computeEffectivePosition(globalViewport: Viewport): boolean;
  54380. /** @hidden */
  54381. _isVisible(): boolean;
  54382. /**
  54383. * @hidden
  54384. */
  54385. render(): boolean;
  54386. /**
  54387. * Dispose and release the lens flare with its associated resources.
  54388. */
  54389. dispose(): void;
  54390. /**
  54391. * Parse a lens flare system from a JSON repressentation
  54392. * @param parsedLensFlareSystem Define the JSON to parse
  54393. * @param scene Define the scene the parsed system should be instantiated in
  54394. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54395. * @returns the parsed system
  54396. */
  54397. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54398. /**
  54399. * Serialize the current Lens Flare System into a JSON representation.
  54400. * @returns the serialized JSON
  54401. */
  54402. serialize(): any;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * This represents one of the lens effect in a `lensFlareSystem`.
  54408. * It controls one of the indiviual texture used in the effect.
  54409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54410. */
  54411. export class LensFlare {
  54412. /**
  54413. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54414. */
  54415. size: number;
  54416. /**
  54417. * 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.
  54418. */
  54419. position: number;
  54420. /**
  54421. * Define the lens color.
  54422. */
  54423. color: Color3;
  54424. /**
  54425. * Define the lens texture.
  54426. */
  54427. texture: Nullable<Texture>;
  54428. /**
  54429. * Define the alpha mode to render this particular lens.
  54430. */
  54431. alphaMode: number;
  54432. private _system;
  54433. /**
  54434. * Creates a new Lens Flare.
  54435. * This represents one of the lens effect in a `lensFlareSystem`.
  54436. * It controls one of the indiviual texture used in the effect.
  54437. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54438. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54439. * @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.
  54440. * @param color Define the lens color
  54441. * @param imgUrl Define the lens texture url
  54442. * @param system Define the `lensFlareSystem` this flare is part of
  54443. * @returns The newly created Lens Flare
  54444. */
  54445. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54446. /**
  54447. * Instantiates a new Lens Flare.
  54448. * This represents one of the lens effect in a `lensFlareSystem`.
  54449. * It controls one of the indiviual texture used in the effect.
  54450. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54451. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54452. * @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.
  54453. * @param color Define the lens color
  54454. * @param imgUrl Define the lens texture url
  54455. * @param system Define the `lensFlareSystem` this flare is part of
  54456. */
  54457. constructor(
  54458. /**
  54459. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54460. */
  54461. size: number,
  54462. /**
  54463. * 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.
  54464. */
  54465. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54466. /**
  54467. * Dispose and release the lens flare with its associated resources.
  54468. */
  54469. dispose(): void;
  54470. }
  54471. }
  54472. declare module BABYLON {
  54473. interface AbstractScene {
  54474. /**
  54475. * The list of lens flare system added to the scene
  54476. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54477. */
  54478. lensFlareSystems: Array<LensFlareSystem>;
  54479. /**
  54480. * Removes the given lens flare system from this scene.
  54481. * @param toRemove The lens flare system to remove
  54482. * @returns The index of the removed lens flare system
  54483. */
  54484. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54485. /**
  54486. * Adds the given lens flare system to this scene
  54487. * @param newLensFlareSystem The lens flare system to add
  54488. */
  54489. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54490. /**
  54491. * Gets a lens flare system using its name
  54492. * @param name defines the name to look for
  54493. * @returns the lens flare system or null if not found
  54494. */
  54495. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54496. /**
  54497. * Gets a lens flare system using its id
  54498. * @param id defines the id to look for
  54499. * @returns the lens flare system or null if not found
  54500. */
  54501. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54502. }
  54503. /**
  54504. * Defines the lens flare scene component responsible to manage any lens flares
  54505. * in a given scene.
  54506. */
  54507. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54508. /**
  54509. * The component name helpfull to identify the component in the list of scene components.
  54510. */
  54511. readonly name: string;
  54512. /**
  54513. * The scene the component belongs to.
  54514. */
  54515. scene: Scene;
  54516. /**
  54517. * Creates a new instance of the component for the given scene
  54518. * @param scene Defines the scene to register the component in
  54519. */
  54520. constructor(scene: Scene);
  54521. /**
  54522. * Registers the component in a given scene
  54523. */
  54524. register(): void;
  54525. /**
  54526. * Rebuilds the elements related to this component in case of
  54527. * context lost for instance.
  54528. */
  54529. rebuild(): void;
  54530. /**
  54531. * Adds all the elements from the container to the scene
  54532. * @param container the container holding the elements
  54533. */
  54534. addFromContainer(container: AbstractScene): void;
  54535. /**
  54536. * Removes all the elements in the container from the scene
  54537. * @param container contains the elements to remove
  54538. * @param dispose if the removed element should be disposed (default: false)
  54539. */
  54540. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54541. /**
  54542. * Serializes the component data to the specified json object
  54543. * @param serializationObject The object to serialize to
  54544. */
  54545. serialize(serializationObject: any): void;
  54546. /**
  54547. * Disposes the component and the associated ressources.
  54548. */
  54549. dispose(): void;
  54550. private _draw;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /** @hidden */
  54555. export var depthPixelShader: {
  54556. name: string;
  54557. shader: string;
  54558. };
  54559. }
  54560. declare module BABYLON {
  54561. /** @hidden */
  54562. export var depthVertexShader: {
  54563. name: string;
  54564. shader: string;
  54565. };
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * This represents a depth renderer in Babylon.
  54570. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54571. */
  54572. export class DepthRenderer {
  54573. private _scene;
  54574. private _depthMap;
  54575. private _effect;
  54576. private readonly _storeNonLinearDepth;
  54577. private readonly _clearColor;
  54578. /** Get if the depth renderer is using packed depth or not */
  54579. readonly isPacked: boolean;
  54580. private _cachedDefines;
  54581. private _camera;
  54582. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54583. enabled: boolean;
  54584. /**
  54585. * Specifiess that the depth renderer will only be used within
  54586. * the camera it is created for.
  54587. * This can help forcing its rendering during the camera processing.
  54588. */
  54589. useOnlyInActiveCamera: boolean;
  54590. /** @hidden */
  54591. static _SceneComponentInitialization: (scene: Scene) => void;
  54592. /**
  54593. * Instantiates a depth renderer
  54594. * @param scene The scene the renderer belongs to
  54595. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54596. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54597. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54598. */
  54599. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54600. /**
  54601. * Creates the depth rendering effect and checks if the effect is ready.
  54602. * @param subMesh The submesh to be used to render the depth map of
  54603. * @param useInstances If multiple world instances should be used
  54604. * @returns if the depth renderer is ready to render the depth map
  54605. */
  54606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54607. /**
  54608. * Gets the texture which the depth map will be written to.
  54609. * @returns The depth map texture
  54610. */
  54611. getDepthMap(): RenderTargetTexture;
  54612. /**
  54613. * Disposes of the depth renderer.
  54614. */
  54615. dispose(): void;
  54616. }
  54617. }
  54618. declare module BABYLON {
  54619. /** @hidden */
  54620. export var minmaxReduxPixelShader: {
  54621. name: string;
  54622. shader: string;
  54623. };
  54624. }
  54625. declare module BABYLON {
  54626. /**
  54627. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54628. * and maximum values from all values of the texture.
  54629. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54630. * The source values are read from the red channel of the texture.
  54631. */
  54632. export class MinMaxReducer {
  54633. /**
  54634. * Observable triggered when the computation has been performed
  54635. */
  54636. onAfterReductionPerformed: Observable<{
  54637. min: number;
  54638. max: number;
  54639. }>;
  54640. protected _camera: Camera;
  54641. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54642. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54643. protected _postProcessManager: PostProcessManager;
  54644. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54645. protected _forceFullscreenViewport: boolean;
  54646. /**
  54647. * Creates a min/max reducer
  54648. * @param camera The camera to use for the post processes
  54649. */
  54650. constructor(camera: Camera);
  54651. /**
  54652. * Gets the texture used to read the values from.
  54653. */
  54654. get sourceTexture(): Nullable<RenderTargetTexture>;
  54655. /**
  54656. * Sets the source texture to read the values from.
  54657. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54658. * because in such textures '1' value must not be taken into account to compute the maximum
  54659. * as this value is used to clear the texture.
  54660. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54661. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54662. * @param depthRedux Indicates if the texture is a depth texture or not
  54663. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54664. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54665. */
  54666. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54667. /**
  54668. * Defines the refresh rate of the computation.
  54669. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54670. */
  54671. get refreshRate(): number;
  54672. set refreshRate(value: number);
  54673. protected _activated: boolean;
  54674. /**
  54675. * Gets the activation status of the reducer
  54676. */
  54677. get activated(): boolean;
  54678. /**
  54679. * Activates the reduction computation.
  54680. * When activated, the observers registered in onAfterReductionPerformed are
  54681. * called after the compuation is performed
  54682. */
  54683. activate(): void;
  54684. /**
  54685. * Deactivates the reduction computation.
  54686. */
  54687. deactivate(): void;
  54688. /**
  54689. * Disposes the min/max reducer
  54690. * @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.
  54691. */
  54692. dispose(disposeAll?: boolean): void;
  54693. }
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54698. */
  54699. export class DepthReducer extends MinMaxReducer {
  54700. private _depthRenderer;
  54701. private _depthRendererId;
  54702. /**
  54703. * Gets the depth renderer used for the computation.
  54704. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54705. */
  54706. get depthRenderer(): Nullable<DepthRenderer>;
  54707. /**
  54708. * Creates a depth reducer
  54709. * @param camera The camera used to render the depth texture
  54710. */
  54711. constructor(camera: Camera);
  54712. /**
  54713. * Sets the depth renderer to use to generate the depth map
  54714. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54715. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54716. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54717. */
  54718. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54719. /** @hidden */
  54720. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54721. /**
  54722. * Activates the reduction computation.
  54723. * When activated, the observers registered in onAfterReductionPerformed are
  54724. * called after the compuation is performed
  54725. */
  54726. activate(): void;
  54727. /**
  54728. * Deactivates the reduction computation.
  54729. */
  54730. deactivate(): void;
  54731. /**
  54732. * Disposes the depth reducer
  54733. * @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.
  54734. */
  54735. dispose(disposeAll?: boolean): void;
  54736. }
  54737. }
  54738. declare module BABYLON {
  54739. /**
  54740. * A CSM implementation allowing casting shadows on large scenes.
  54741. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54742. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54743. */
  54744. export class CascadedShadowGenerator extends ShadowGenerator {
  54745. private static readonly frustumCornersNDCSpace;
  54746. /**
  54747. * Name of the CSM class
  54748. */
  54749. static CLASSNAME: string;
  54750. /**
  54751. * Defines the default number of cascades used by the CSM.
  54752. */
  54753. static readonly DEFAULT_CASCADES_COUNT: number;
  54754. /**
  54755. * Defines the minimum number of cascades used by the CSM.
  54756. */
  54757. static readonly MIN_CASCADES_COUNT: number;
  54758. /**
  54759. * Defines the maximum number of cascades used by the CSM.
  54760. */
  54761. static readonly MAX_CASCADES_COUNT: number;
  54762. protected _validateFilter(filter: number): number;
  54763. /**
  54764. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54765. */
  54766. penumbraDarkness: number;
  54767. private _numCascades;
  54768. /**
  54769. * Gets or set the number of cascades used by the CSM.
  54770. */
  54771. get numCascades(): number;
  54772. set numCascades(value: number);
  54773. /**
  54774. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54775. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54776. */
  54777. stabilizeCascades: boolean;
  54778. private _freezeShadowCastersBoundingInfo;
  54779. private _freezeShadowCastersBoundingInfoObservable;
  54780. /**
  54781. * Enables or disables the shadow casters bounding info computation.
  54782. * If your shadow casters don't move, you can disable this feature.
  54783. * If it is enabled, the bounding box computation is done every frame.
  54784. */
  54785. get freezeShadowCastersBoundingInfo(): boolean;
  54786. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54787. private _scbiMin;
  54788. private _scbiMax;
  54789. protected _computeShadowCastersBoundingInfo(): void;
  54790. protected _shadowCastersBoundingInfo: BoundingInfo;
  54791. /**
  54792. * Gets or sets the shadow casters bounding info.
  54793. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54794. * so that the system won't overwrite the bounds you provide
  54795. */
  54796. get shadowCastersBoundingInfo(): BoundingInfo;
  54797. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54798. protected _breaksAreDirty: boolean;
  54799. protected _minDistance: number;
  54800. protected _maxDistance: number;
  54801. /**
  54802. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54803. *
  54804. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54805. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54806. * @param min minimal distance for the breaks (default to 0.)
  54807. * @param max maximal distance for the breaks (default to 1.)
  54808. */
  54809. setMinMaxDistance(min: number, max: number): void;
  54810. /** Gets the minimal distance used in the cascade break computation */
  54811. get minDistance(): number;
  54812. /** Gets the maximal distance used in the cascade break computation */
  54813. get maxDistance(): number;
  54814. /**
  54815. * Gets the class name of that object
  54816. * @returns "CascadedShadowGenerator"
  54817. */
  54818. getClassName(): string;
  54819. private _cascadeMinExtents;
  54820. private _cascadeMaxExtents;
  54821. /**
  54822. * Gets a cascade minimum extents
  54823. * @param cascadeIndex index of the cascade
  54824. * @returns the minimum cascade extents
  54825. */
  54826. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54827. /**
  54828. * Gets a cascade maximum extents
  54829. * @param cascadeIndex index of the cascade
  54830. * @returns the maximum cascade extents
  54831. */
  54832. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54833. private _cascades;
  54834. private _currentLayer;
  54835. private _viewSpaceFrustumsZ;
  54836. private _viewMatrices;
  54837. private _projectionMatrices;
  54838. private _transformMatrices;
  54839. private _transformMatricesAsArray;
  54840. private _frustumLengths;
  54841. private _lightSizeUVCorrection;
  54842. private _depthCorrection;
  54843. private _frustumCornersWorldSpace;
  54844. private _frustumCenter;
  54845. private _shadowCameraPos;
  54846. private _shadowMaxZ;
  54847. /**
  54848. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54849. * It defaults to camera.maxZ
  54850. */
  54851. get shadowMaxZ(): number;
  54852. /**
  54853. * Sets the shadow max z distance.
  54854. */
  54855. set shadowMaxZ(value: number);
  54856. protected _debug: boolean;
  54857. /**
  54858. * Gets or sets the debug flag.
  54859. * When enabled, the cascades are materialized by different colors on the screen.
  54860. */
  54861. get debug(): boolean;
  54862. set debug(dbg: boolean);
  54863. private _depthClamp;
  54864. /**
  54865. * Gets or sets the depth clamping value.
  54866. *
  54867. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54868. * to account for the shadow casters far away.
  54869. *
  54870. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54871. */
  54872. get depthClamp(): boolean;
  54873. set depthClamp(value: boolean);
  54874. private _cascadeBlendPercentage;
  54875. /**
  54876. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54877. * It defaults to 0.1 (10% blending).
  54878. */
  54879. get cascadeBlendPercentage(): number;
  54880. set cascadeBlendPercentage(value: number);
  54881. private _lambda;
  54882. /**
  54883. * Gets or set the lambda parameter.
  54884. * This parameter is used to split the camera frustum and create the cascades.
  54885. * 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.
  54886. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54887. */
  54888. get lambda(): number;
  54889. set lambda(value: number);
  54890. /**
  54891. * Gets the view matrix corresponding to a given cascade
  54892. * @param cascadeNum cascade to retrieve the view matrix from
  54893. * @returns the cascade view matrix
  54894. */
  54895. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54896. /**
  54897. * Gets the projection matrix corresponding to a given cascade
  54898. * @param cascadeNum cascade to retrieve the projection matrix from
  54899. * @returns the cascade projection matrix
  54900. */
  54901. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54902. /**
  54903. * Gets the transformation matrix corresponding to a given cascade
  54904. * @param cascadeNum cascade to retrieve the transformation matrix from
  54905. * @returns the cascade transformation matrix
  54906. */
  54907. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54908. private _depthRenderer;
  54909. /**
  54910. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54911. *
  54912. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54913. *
  54914. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54915. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54916. * @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
  54917. */
  54918. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54919. private _depthReducer;
  54920. private _autoCalcDepthBounds;
  54921. /**
  54922. * Gets or sets the autoCalcDepthBounds property.
  54923. *
  54924. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54925. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54926. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54927. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54928. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54929. */
  54930. get autoCalcDepthBounds(): boolean;
  54931. set autoCalcDepthBounds(value: boolean);
  54932. /**
  54933. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54934. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54935. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54936. * for setting the refresh rate on the renderer yourself!
  54937. */
  54938. get autoCalcDepthBoundsRefreshRate(): number;
  54939. set autoCalcDepthBoundsRefreshRate(value: number);
  54940. /**
  54941. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54942. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54943. * you change the camera near/far planes!
  54944. */
  54945. splitFrustum(): void;
  54946. private _splitFrustum;
  54947. private _computeMatrices;
  54948. private _computeFrustumInWorldSpace;
  54949. private _computeCascadeFrustum;
  54950. /**
  54951. * Support test.
  54952. */
  54953. static get IsSupported(): boolean;
  54954. /** @hidden */
  54955. static _SceneComponentInitialization: (scene: Scene) => void;
  54956. /**
  54957. * Creates a Cascaded Shadow Generator object.
  54958. * A ShadowGenerator is the required tool to use the shadows.
  54959. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54960. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54961. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54962. * @param light The directional light object generating the shadows.
  54963. * @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.
  54964. */
  54965. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54966. protected _initializeGenerator(): void;
  54967. protected _createTargetRenderTexture(): void;
  54968. protected _initializeShadowMap(): void;
  54969. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54970. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54971. /**
  54972. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54973. * @param defines Defines of the material we want to update
  54974. * @param lightIndex Index of the light in the enabled light list of the material
  54975. */
  54976. prepareDefines(defines: any, lightIndex: number): void;
  54977. /**
  54978. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54979. * defined in the generator but impacting the effect).
  54980. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54981. * @param effect The effect we are binfing the information for
  54982. */
  54983. bindShadowLight(lightIndex: string, effect: Effect): void;
  54984. /**
  54985. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54986. * (eq to view projection * shadow projection matrices)
  54987. * @returns The transform matrix used to create the shadow map
  54988. */
  54989. getTransformMatrix(): Matrix;
  54990. /**
  54991. * Disposes the ShadowGenerator.
  54992. * Returns nothing.
  54993. */
  54994. dispose(): void;
  54995. /**
  54996. * Serializes the shadow generator setup to a json object.
  54997. * @returns The serialized JSON object
  54998. */
  54999. serialize(): any;
  55000. /**
  55001. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55002. * @param parsedShadowGenerator The JSON object to parse
  55003. * @param scene The scene to create the shadow map for
  55004. * @returns The parsed shadow generator
  55005. */
  55006. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55007. }
  55008. }
  55009. declare module BABYLON {
  55010. /**
  55011. * Defines the shadow generator component responsible to manage any shadow generators
  55012. * in a given scene.
  55013. */
  55014. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55015. /**
  55016. * The component name helpfull to identify the component in the list of scene components.
  55017. */
  55018. readonly name: string;
  55019. /**
  55020. * The scene the component belongs to.
  55021. */
  55022. scene: Scene;
  55023. /**
  55024. * Creates a new instance of the component for the given scene
  55025. * @param scene Defines the scene to register the component in
  55026. */
  55027. constructor(scene: Scene);
  55028. /**
  55029. * Registers the component in a given scene
  55030. */
  55031. register(): void;
  55032. /**
  55033. * Rebuilds the elements related to this component in case of
  55034. * context lost for instance.
  55035. */
  55036. rebuild(): void;
  55037. /**
  55038. * Serializes the component data to the specified json object
  55039. * @param serializationObject The object to serialize to
  55040. */
  55041. serialize(serializationObject: any): void;
  55042. /**
  55043. * Adds all the elements from the container to the scene
  55044. * @param container the container holding the elements
  55045. */
  55046. addFromContainer(container: AbstractScene): void;
  55047. /**
  55048. * Removes all the elements in the container from the scene
  55049. * @param container contains the elements to remove
  55050. * @param dispose if the removed element should be disposed (default: false)
  55051. */
  55052. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55053. /**
  55054. * Rebuilds the elements related to this component in case of
  55055. * context lost for instance.
  55056. */
  55057. dispose(): void;
  55058. private _gatherRenderTargets;
  55059. }
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * A point light is a light defined by an unique point in world space.
  55064. * The light is emitted in every direction from this point.
  55065. * A good example of a point light is a standard light bulb.
  55066. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55067. */
  55068. export class PointLight extends ShadowLight {
  55069. private _shadowAngle;
  55070. /**
  55071. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55072. * This specifies what angle the shadow will use to be created.
  55073. *
  55074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55075. */
  55076. get shadowAngle(): number;
  55077. /**
  55078. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55079. * This specifies what angle the shadow will use to be created.
  55080. *
  55081. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55082. */
  55083. set shadowAngle(value: number);
  55084. /**
  55085. * Gets the direction if it has been set.
  55086. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55087. */
  55088. get direction(): Vector3;
  55089. /**
  55090. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55091. */
  55092. set direction(value: Vector3);
  55093. /**
  55094. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55095. * A PointLight emits the light in every direction.
  55096. * It can cast shadows.
  55097. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55098. * ```javascript
  55099. * var pointLight = new PointLight("pl", camera.position, scene);
  55100. * ```
  55101. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55102. * @param name The light friendly name
  55103. * @param position The position of the point light in the scene
  55104. * @param scene The scene the lights belongs to
  55105. */
  55106. constructor(name: string, position: Vector3, scene: Scene);
  55107. /**
  55108. * Returns the string "PointLight"
  55109. * @returns the class name
  55110. */
  55111. getClassName(): string;
  55112. /**
  55113. * Returns the integer 0.
  55114. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55115. */
  55116. getTypeID(): number;
  55117. /**
  55118. * Specifies wether or not the shadowmap should be a cube texture.
  55119. * @returns true if the shadowmap needs to be a cube texture.
  55120. */
  55121. needCube(): boolean;
  55122. /**
  55123. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55124. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55125. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55126. */
  55127. getShadowDirection(faceIndex?: number): Vector3;
  55128. /**
  55129. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55130. * - fov = PI / 2
  55131. * - aspect ratio : 1.0
  55132. * - z-near and far equal to the active camera minZ and maxZ.
  55133. * Returns the PointLight.
  55134. */
  55135. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55136. protected _buildUniformLayout(): void;
  55137. /**
  55138. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55139. * @param effect The effect to update
  55140. * @param lightIndex The index of the light in the effect to update
  55141. * @returns The point light
  55142. */
  55143. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55144. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55145. /**
  55146. * Prepares the list of defines specific to the light type.
  55147. * @param defines the list of defines
  55148. * @param lightIndex defines the index of the light for the effect
  55149. */
  55150. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55151. }
  55152. }
  55153. declare module BABYLON {
  55154. /**
  55155. * Header information of HDR texture files.
  55156. */
  55157. export interface HDRInfo {
  55158. /**
  55159. * The height of the texture in pixels.
  55160. */
  55161. height: number;
  55162. /**
  55163. * The width of the texture in pixels.
  55164. */
  55165. width: number;
  55166. /**
  55167. * The index of the beginning of the data in the binary file.
  55168. */
  55169. dataPosition: number;
  55170. }
  55171. /**
  55172. * This groups tools to convert HDR texture to native colors array.
  55173. */
  55174. export class HDRTools {
  55175. private static Ldexp;
  55176. private static Rgbe2float;
  55177. private static readStringLine;
  55178. /**
  55179. * Reads header information from an RGBE texture stored in a native array.
  55180. * More information on this format are available here:
  55181. * https://en.wikipedia.org/wiki/RGBE_image_format
  55182. *
  55183. * @param uint8array The binary file stored in native array.
  55184. * @return The header information.
  55185. */
  55186. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55187. /**
  55188. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55189. * This RGBE texture needs to store the information as a panorama.
  55190. *
  55191. * More information on this format are available here:
  55192. * https://en.wikipedia.org/wiki/RGBE_image_format
  55193. *
  55194. * @param buffer The binary file stored in an array buffer.
  55195. * @param size The expected size of the extracted cubemap.
  55196. * @return The Cube Map information.
  55197. */
  55198. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55199. /**
  55200. * Returns the pixels data extracted from an RGBE texture.
  55201. * This pixels will be stored left to right up to down in the R G B order in one array.
  55202. *
  55203. * More information on this format are available here:
  55204. * https://en.wikipedia.org/wiki/RGBE_image_format
  55205. *
  55206. * @param uint8array The binary file stored in an array buffer.
  55207. * @param hdrInfo The header information of the file.
  55208. * @return The pixels data in RGB right to left up to down order.
  55209. */
  55210. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55211. private static RGBE_ReadPixels_RLE;
  55212. }
  55213. }
  55214. declare module BABYLON {
  55215. /**
  55216. * This represents a texture coming from an HDR input.
  55217. *
  55218. * The only supported format is currently panorama picture stored in RGBE format.
  55219. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55220. */
  55221. export class HDRCubeTexture extends BaseTexture {
  55222. private static _facesMapping;
  55223. private _generateHarmonics;
  55224. private _noMipmap;
  55225. private _textureMatrix;
  55226. private _size;
  55227. private _onLoad;
  55228. private _onError;
  55229. /**
  55230. * The texture URL.
  55231. */
  55232. url: string;
  55233. /**
  55234. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55235. */
  55236. coordinatesMode: number;
  55237. protected _isBlocking: boolean;
  55238. /**
  55239. * Sets wether or not the texture is blocking during loading.
  55240. */
  55241. set isBlocking(value: boolean);
  55242. /**
  55243. * Gets wether or not the texture is blocking during loading.
  55244. */
  55245. get isBlocking(): boolean;
  55246. protected _rotationY: number;
  55247. /**
  55248. * Sets texture matrix rotation angle around Y axis in radians.
  55249. */
  55250. set rotationY(value: number);
  55251. /**
  55252. * Gets texture matrix rotation angle around Y axis radians.
  55253. */
  55254. get rotationY(): number;
  55255. /**
  55256. * Gets or sets the center of the bounding box associated with the cube texture
  55257. * It must define where the camera used to render the texture was set
  55258. */
  55259. boundingBoxPosition: Vector3;
  55260. private _boundingBoxSize;
  55261. /**
  55262. * Gets or sets the size of the bounding box associated with the cube texture
  55263. * When defined, the cubemap will switch to local mode
  55264. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55265. * @example https://www.babylonjs-playground.com/#RNASML
  55266. */
  55267. set boundingBoxSize(value: Vector3);
  55268. get boundingBoxSize(): Vector3;
  55269. /**
  55270. * Instantiates an HDRTexture from the following parameters.
  55271. *
  55272. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55273. * @param scene The scene the texture will be used in
  55274. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55275. * @param noMipmap Forces to not generate the mipmap if true
  55276. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55277. * @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)
  55278. * @param reserved Reserved flag for internal use.
  55279. */
  55280. 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>);
  55281. /**
  55282. * Get the current class name of the texture useful for serialization or dynamic coding.
  55283. * @returns "HDRCubeTexture"
  55284. */
  55285. getClassName(): string;
  55286. /**
  55287. * Occurs when the file is raw .hdr file.
  55288. */
  55289. private loadTexture;
  55290. clone(): HDRCubeTexture;
  55291. delayLoad(): void;
  55292. /**
  55293. * Get the texture reflection matrix used to rotate/transform the reflection.
  55294. * @returns the reflection matrix
  55295. */
  55296. getReflectionTextureMatrix(): Matrix;
  55297. /**
  55298. * Set the texture reflection matrix used to rotate/transform the reflection.
  55299. * @param value Define the reflection matrix to set
  55300. */
  55301. setReflectionTextureMatrix(value: Matrix): void;
  55302. /**
  55303. * Parses a JSON representation of an HDR Texture in order to create the texture
  55304. * @param parsedTexture Define the JSON representation
  55305. * @param scene Define the scene the texture should be created in
  55306. * @param rootUrl Define the root url in case we need to load relative dependencies
  55307. * @returns the newly created texture after parsing
  55308. */
  55309. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55310. serialize(): any;
  55311. }
  55312. }
  55313. declare module BABYLON {
  55314. /**
  55315. * Class used to control physics engine
  55316. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55317. */
  55318. export class PhysicsEngine implements IPhysicsEngine {
  55319. private _physicsPlugin;
  55320. /**
  55321. * Global value used to control the smallest number supported by the simulation
  55322. */
  55323. static Epsilon: number;
  55324. private _impostors;
  55325. private _joints;
  55326. private _subTimeStep;
  55327. /**
  55328. * Gets the gravity vector used by the simulation
  55329. */
  55330. gravity: Vector3;
  55331. /**
  55332. * Factory used to create the default physics plugin.
  55333. * @returns The default physics plugin
  55334. */
  55335. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55336. /**
  55337. * Creates a new Physics Engine
  55338. * @param gravity defines the gravity vector used by the simulation
  55339. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55340. */
  55341. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55342. /**
  55343. * Sets the gravity vector used by the simulation
  55344. * @param gravity defines the gravity vector to use
  55345. */
  55346. setGravity(gravity: Vector3): void;
  55347. /**
  55348. * Set the time step of the physics engine.
  55349. * Default is 1/60.
  55350. * To slow it down, enter 1/600 for example.
  55351. * To speed it up, 1/30
  55352. * @param newTimeStep defines the new timestep to apply to this world.
  55353. */
  55354. setTimeStep(newTimeStep?: number): void;
  55355. /**
  55356. * Get the time step of the physics engine.
  55357. * @returns the current time step
  55358. */
  55359. getTimeStep(): number;
  55360. /**
  55361. * Set the sub time step of the physics engine.
  55362. * Default is 0 meaning there is no sub steps
  55363. * To increase physics resolution precision, set a small value (like 1 ms)
  55364. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55365. */
  55366. setSubTimeStep(subTimeStep?: number): void;
  55367. /**
  55368. * Get the sub time step of the physics engine.
  55369. * @returns the current sub time step
  55370. */
  55371. getSubTimeStep(): number;
  55372. /**
  55373. * Release all resources
  55374. */
  55375. dispose(): void;
  55376. /**
  55377. * Gets the name of the current physics plugin
  55378. * @returns the name of the plugin
  55379. */
  55380. getPhysicsPluginName(): string;
  55381. /**
  55382. * Adding a new impostor for the impostor tracking.
  55383. * This will be done by the impostor itself.
  55384. * @param impostor the impostor to add
  55385. */
  55386. addImpostor(impostor: PhysicsImpostor): void;
  55387. /**
  55388. * Remove an impostor from the engine.
  55389. * This impostor and its mesh will not longer be updated by the physics engine.
  55390. * @param impostor the impostor to remove
  55391. */
  55392. removeImpostor(impostor: PhysicsImpostor): void;
  55393. /**
  55394. * Add a joint to the physics engine
  55395. * @param mainImpostor defines the main impostor to which the joint is added.
  55396. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55397. * @param joint defines the joint that will connect both impostors.
  55398. */
  55399. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55400. /**
  55401. * Removes a joint from the simulation
  55402. * @param mainImpostor defines the impostor used with the joint
  55403. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55404. * @param joint defines the joint to remove
  55405. */
  55406. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55407. /**
  55408. * Called by the scene. No need to call it.
  55409. * @param delta defines the timespam between frames
  55410. */
  55411. _step(delta: number): void;
  55412. /**
  55413. * Gets the current plugin used to run the simulation
  55414. * @returns current plugin
  55415. */
  55416. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55417. /**
  55418. * Gets the list of physic impostors
  55419. * @returns an array of PhysicsImpostor
  55420. */
  55421. getImpostors(): Array<PhysicsImpostor>;
  55422. /**
  55423. * Gets the impostor for a physics enabled object
  55424. * @param object defines the object impersonated by the impostor
  55425. * @returns the PhysicsImpostor or null if not found
  55426. */
  55427. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55428. /**
  55429. * Gets the impostor for a physics body object
  55430. * @param body defines physics body used by the impostor
  55431. * @returns the PhysicsImpostor or null if not found
  55432. */
  55433. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55434. /**
  55435. * Does a raycast in the physics world
  55436. * @param from when should the ray start?
  55437. * @param to when should the ray end?
  55438. * @returns PhysicsRaycastResult
  55439. */
  55440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55441. }
  55442. }
  55443. declare module BABYLON {
  55444. /** @hidden */
  55445. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55446. private _useDeltaForWorldStep;
  55447. world: any;
  55448. name: string;
  55449. private _physicsMaterials;
  55450. private _fixedTimeStep;
  55451. private _cannonRaycastResult;
  55452. private _raycastResult;
  55453. private _physicsBodysToRemoveAfterStep;
  55454. BJSCANNON: any;
  55455. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55456. setGravity(gravity: Vector3): void;
  55457. setTimeStep(timeStep: number): void;
  55458. getTimeStep(): number;
  55459. executeStep(delta: number): void;
  55460. private _removeMarkedPhysicsBodiesFromWorld;
  55461. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55462. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55463. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55464. private _processChildMeshes;
  55465. removePhysicsBody(impostor: PhysicsImpostor): void;
  55466. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55467. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55468. private _addMaterial;
  55469. private _checkWithEpsilon;
  55470. private _createShape;
  55471. private _createHeightmap;
  55472. private _minus90X;
  55473. private _plus90X;
  55474. private _tmpPosition;
  55475. private _tmpDeltaPosition;
  55476. private _tmpUnityRotation;
  55477. private _updatePhysicsBodyTransformation;
  55478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55480. isSupported(): boolean;
  55481. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55482. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55483. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55484. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55485. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55486. getBodyMass(impostor: PhysicsImpostor): number;
  55487. getBodyFriction(impostor: PhysicsImpostor): number;
  55488. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55489. getBodyRestitution(impostor: PhysicsImpostor): number;
  55490. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55491. sleepBody(impostor: PhysicsImpostor): void;
  55492. wakeUpBody(impostor: PhysicsImpostor): void;
  55493. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55494. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55497. getRadius(impostor: PhysicsImpostor): number;
  55498. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55499. dispose(): void;
  55500. private _extendNamespace;
  55501. /**
  55502. * Does a raycast in the physics world
  55503. * @param from when should the ray start?
  55504. * @param to when should the ray end?
  55505. * @returns PhysicsRaycastResult
  55506. */
  55507. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55508. }
  55509. }
  55510. declare module BABYLON {
  55511. /** @hidden */
  55512. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55513. world: any;
  55514. name: string;
  55515. BJSOIMO: any;
  55516. private _raycastResult;
  55517. constructor(iterations?: number, oimoInjection?: any);
  55518. setGravity(gravity: Vector3): void;
  55519. setTimeStep(timeStep: number): void;
  55520. getTimeStep(): number;
  55521. private _tmpImpostorsArray;
  55522. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55523. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55524. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55525. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55526. private _tmpPositionVector;
  55527. removePhysicsBody(impostor: PhysicsImpostor): void;
  55528. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55529. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55530. isSupported(): boolean;
  55531. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55532. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55533. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55534. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55535. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55536. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55537. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55538. getBodyMass(impostor: PhysicsImpostor): number;
  55539. getBodyFriction(impostor: PhysicsImpostor): number;
  55540. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55541. getBodyRestitution(impostor: PhysicsImpostor): number;
  55542. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55543. sleepBody(impostor: PhysicsImpostor): void;
  55544. wakeUpBody(impostor: PhysicsImpostor): void;
  55545. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55546. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55547. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55548. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55549. getRadius(impostor: PhysicsImpostor): number;
  55550. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55551. dispose(): void;
  55552. /**
  55553. * Does a raycast in the physics world
  55554. * @param from when should the ray start?
  55555. * @param to when should the ray end?
  55556. * @returns PhysicsRaycastResult
  55557. */
  55558. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55559. }
  55560. }
  55561. declare module BABYLON {
  55562. /**
  55563. * Class containing static functions to help procedurally build meshes
  55564. */
  55565. export class RibbonBuilder {
  55566. /**
  55567. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55568. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55569. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55570. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55571. * * 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
  55572. * * 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
  55573. * * 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
  55574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55575. * * 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
  55576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55577. * * 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
  55578. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55579. * * 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
  55580. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55582. * @param name defines the name of the mesh
  55583. * @param options defines the options used to create the mesh
  55584. * @param scene defines the hosting scene
  55585. * @returns the ribbon mesh
  55586. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55588. */
  55589. static CreateRibbon(name: string, options: {
  55590. pathArray: Vector3[][];
  55591. closeArray?: boolean;
  55592. closePath?: boolean;
  55593. offset?: number;
  55594. updatable?: boolean;
  55595. sideOrientation?: number;
  55596. frontUVs?: Vector4;
  55597. backUVs?: Vector4;
  55598. instance?: Mesh;
  55599. invertUV?: boolean;
  55600. uvs?: Vector2[];
  55601. colors?: Color4[];
  55602. }, scene?: Nullable<Scene>): Mesh;
  55603. }
  55604. }
  55605. declare module BABYLON {
  55606. /**
  55607. * Class containing static functions to help procedurally build meshes
  55608. */
  55609. export class ShapeBuilder {
  55610. /**
  55611. * 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.
  55612. * * 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.
  55613. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55614. * * 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.
  55615. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55616. * * 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
  55617. * * 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
  55618. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55620. * * 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
  55621. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55623. * @param name defines the name of the mesh
  55624. * @param options defines the options used to create the mesh
  55625. * @param scene defines the hosting scene
  55626. * @returns the extruded shape mesh
  55627. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55629. */
  55630. static ExtrudeShape(name: string, options: {
  55631. shape: Vector3[];
  55632. path: Vector3[];
  55633. scale?: number;
  55634. rotation?: number;
  55635. cap?: number;
  55636. updatable?: boolean;
  55637. sideOrientation?: number;
  55638. frontUVs?: Vector4;
  55639. backUVs?: Vector4;
  55640. instance?: Mesh;
  55641. invertUV?: boolean;
  55642. }, scene?: Nullable<Scene>): Mesh;
  55643. /**
  55644. * Creates an custom extruded shape mesh.
  55645. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55646. * * 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.
  55647. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55648. * * 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
  55649. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55650. * * 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
  55651. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55652. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55653. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55654. * * 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
  55655. * * 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
  55656. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55658. * * 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
  55659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55661. * @param name defines the name of the mesh
  55662. * @param options defines the options used to create the mesh
  55663. * @param scene defines the hosting scene
  55664. * @returns the custom extruded shape mesh
  55665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55668. */
  55669. static ExtrudeShapeCustom(name: string, options: {
  55670. shape: Vector3[];
  55671. path: Vector3[];
  55672. scaleFunction?: any;
  55673. rotationFunction?: any;
  55674. ribbonCloseArray?: boolean;
  55675. ribbonClosePath?: boolean;
  55676. cap?: number;
  55677. updatable?: boolean;
  55678. sideOrientation?: number;
  55679. frontUVs?: Vector4;
  55680. backUVs?: Vector4;
  55681. instance?: Mesh;
  55682. invertUV?: boolean;
  55683. }, scene?: Nullable<Scene>): Mesh;
  55684. private static _ExtrudeShapeGeneric;
  55685. }
  55686. }
  55687. declare module BABYLON {
  55688. /**
  55689. * AmmoJS Physics plugin
  55690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55691. * @see https://github.com/kripken/ammo.js/
  55692. */
  55693. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55694. private _useDeltaForWorldStep;
  55695. /**
  55696. * Reference to the Ammo library
  55697. */
  55698. bjsAMMO: any;
  55699. /**
  55700. * Created ammoJS world which physics bodies are added to
  55701. */
  55702. world: any;
  55703. /**
  55704. * Name of the plugin
  55705. */
  55706. name: string;
  55707. private _timeStep;
  55708. private _fixedTimeStep;
  55709. private _maxSteps;
  55710. private _tmpQuaternion;
  55711. private _tmpAmmoTransform;
  55712. private _tmpAmmoQuaternion;
  55713. private _tmpAmmoConcreteContactResultCallback;
  55714. private _collisionConfiguration;
  55715. private _dispatcher;
  55716. private _overlappingPairCache;
  55717. private _solver;
  55718. private _softBodySolver;
  55719. private _tmpAmmoVectorA;
  55720. private _tmpAmmoVectorB;
  55721. private _tmpAmmoVectorC;
  55722. private _tmpAmmoVectorD;
  55723. private _tmpContactCallbackResult;
  55724. private _tmpAmmoVectorRCA;
  55725. private _tmpAmmoVectorRCB;
  55726. private _raycastResult;
  55727. private static readonly DISABLE_COLLISION_FLAG;
  55728. private static readonly KINEMATIC_FLAG;
  55729. private static readonly DISABLE_DEACTIVATION_FLAG;
  55730. /**
  55731. * Initializes the ammoJS plugin
  55732. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55733. * @param ammoInjection can be used to inject your own ammo reference
  55734. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55735. */
  55736. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55737. /**
  55738. * Sets the gravity of the physics world (m/(s^2))
  55739. * @param gravity Gravity to set
  55740. */
  55741. setGravity(gravity: Vector3): void;
  55742. /**
  55743. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55744. * @param timeStep timestep to use in seconds
  55745. */
  55746. setTimeStep(timeStep: number): void;
  55747. /**
  55748. * 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)
  55749. * @param fixedTimeStep fixedTimeStep to use in seconds
  55750. */
  55751. setFixedTimeStep(fixedTimeStep: number): void;
  55752. /**
  55753. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55754. * @param maxSteps the maximum number of steps by the physics engine per frame
  55755. */
  55756. setMaxSteps(maxSteps: number): void;
  55757. /**
  55758. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55759. * @returns the current timestep in seconds
  55760. */
  55761. getTimeStep(): number;
  55762. /**
  55763. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55764. */
  55765. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55766. private _isImpostorInContact;
  55767. private _isImpostorPairInContact;
  55768. private _stepSimulation;
  55769. /**
  55770. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55771. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55772. * After the step the babylon meshes are set to the position of the physics imposters
  55773. * @param delta amount of time to step forward
  55774. * @param impostors array of imposters to update before/after the step
  55775. */
  55776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55777. /**
  55778. * Update babylon mesh to match physics world object
  55779. * @param impostor imposter to match
  55780. */
  55781. private _afterSoftStep;
  55782. /**
  55783. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55784. * @param impostor imposter to match
  55785. */
  55786. private _ropeStep;
  55787. /**
  55788. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55789. * @param impostor imposter to match
  55790. */
  55791. private _softbodyOrClothStep;
  55792. private _tmpMatrix;
  55793. /**
  55794. * Applies an impulse on the imposter
  55795. * @param impostor imposter to apply impulse to
  55796. * @param force amount of force to be applied to the imposter
  55797. * @param contactPoint the location to apply the impulse on the imposter
  55798. */
  55799. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55800. /**
  55801. * Applies a force on the imposter
  55802. * @param impostor imposter to apply force
  55803. * @param force amount of force to be applied to the imposter
  55804. * @param contactPoint the location to apply the force on the imposter
  55805. */
  55806. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55807. /**
  55808. * Creates a physics body using the plugin
  55809. * @param impostor the imposter to create the physics body on
  55810. */
  55811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55812. /**
  55813. * Removes the physics body from the imposter and disposes of the body's memory
  55814. * @param impostor imposter to remove the physics body from
  55815. */
  55816. removePhysicsBody(impostor: PhysicsImpostor): void;
  55817. /**
  55818. * Generates a joint
  55819. * @param impostorJoint the imposter joint to create the joint with
  55820. */
  55821. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55822. /**
  55823. * Removes a joint
  55824. * @param impostorJoint the imposter joint to remove the joint from
  55825. */
  55826. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55827. private _addMeshVerts;
  55828. /**
  55829. * Initialise the soft body vertices to match its object's (mesh) vertices
  55830. * Softbody vertices (nodes) are in world space and to match this
  55831. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55832. * @param impostor to create the softbody for
  55833. */
  55834. private _softVertexData;
  55835. /**
  55836. * Create an impostor's soft body
  55837. * @param impostor to create the softbody for
  55838. */
  55839. private _createSoftbody;
  55840. /**
  55841. * Create cloth for an impostor
  55842. * @param impostor to create the softbody for
  55843. */
  55844. private _createCloth;
  55845. /**
  55846. * Create rope for an impostor
  55847. * @param impostor to create the softbody for
  55848. */
  55849. private _createRope;
  55850. /**
  55851. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55852. * @param impostor to create the custom physics shape for
  55853. */
  55854. private _createCustom;
  55855. private _addHullVerts;
  55856. private _createShape;
  55857. /**
  55858. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55859. * @param impostor imposter containing the physics body and babylon object
  55860. */
  55861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55862. /**
  55863. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55864. * @param impostor imposter containing the physics body and babylon object
  55865. * @param newPosition new position
  55866. * @param newRotation new rotation
  55867. */
  55868. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55869. /**
  55870. * If this plugin is supported
  55871. * @returns true if its supported
  55872. */
  55873. isSupported(): boolean;
  55874. /**
  55875. * Sets the linear velocity of the physics body
  55876. * @param impostor imposter to set the velocity on
  55877. * @param velocity velocity to set
  55878. */
  55879. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55880. /**
  55881. * Sets the angular velocity of the physics body
  55882. * @param impostor imposter to set the velocity on
  55883. * @param velocity velocity to set
  55884. */
  55885. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55886. /**
  55887. * gets the linear velocity
  55888. * @param impostor imposter to get linear velocity from
  55889. * @returns linear velocity
  55890. */
  55891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55892. /**
  55893. * gets the angular velocity
  55894. * @param impostor imposter to get angular velocity from
  55895. * @returns angular velocity
  55896. */
  55897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55898. /**
  55899. * Sets the mass of physics body
  55900. * @param impostor imposter to set the mass on
  55901. * @param mass mass to set
  55902. */
  55903. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55904. /**
  55905. * Gets the mass of the physics body
  55906. * @param impostor imposter to get the mass from
  55907. * @returns mass
  55908. */
  55909. getBodyMass(impostor: PhysicsImpostor): number;
  55910. /**
  55911. * Gets friction of the impostor
  55912. * @param impostor impostor to get friction from
  55913. * @returns friction value
  55914. */
  55915. getBodyFriction(impostor: PhysicsImpostor): number;
  55916. /**
  55917. * Sets friction of the impostor
  55918. * @param impostor impostor to set friction on
  55919. * @param friction friction value
  55920. */
  55921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55922. /**
  55923. * Gets restitution of the impostor
  55924. * @param impostor impostor to get restitution from
  55925. * @returns restitution value
  55926. */
  55927. getBodyRestitution(impostor: PhysicsImpostor): number;
  55928. /**
  55929. * Sets resitution of the impostor
  55930. * @param impostor impostor to set resitution on
  55931. * @param restitution resitution value
  55932. */
  55933. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55934. /**
  55935. * Gets pressure inside the impostor
  55936. * @param impostor impostor to get pressure from
  55937. * @returns pressure value
  55938. */
  55939. getBodyPressure(impostor: PhysicsImpostor): number;
  55940. /**
  55941. * Sets pressure inside a soft body impostor
  55942. * Cloth and rope must remain 0 pressure
  55943. * @param impostor impostor to set pressure on
  55944. * @param pressure pressure value
  55945. */
  55946. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55947. /**
  55948. * Gets stiffness of the impostor
  55949. * @param impostor impostor to get stiffness from
  55950. * @returns pressure value
  55951. */
  55952. getBodyStiffness(impostor: PhysicsImpostor): number;
  55953. /**
  55954. * Sets stiffness of the impostor
  55955. * @param impostor impostor to set stiffness on
  55956. * @param stiffness stiffness value from 0 to 1
  55957. */
  55958. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55959. /**
  55960. * Gets velocityIterations of the impostor
  55961. * @param impostor impostor to get velocity iterations from
  55962. * @returns velocityIterations value
  55963. */
  55964. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55965. /**
  55966. * Sets velocityIterations of the impostor
  55967. * @param impostor impostor to set velocity iterations on
  55968. * @param velocityIterations velocityIterations value
  55969. */
  55970. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55971. /**
  55972. * Gets positionIterations of the impostor
  55973. * @param impostor impostor to get position iterations from
  55974. * @returns positionIterations value
  55975. */
  55976. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55977. /**
  55978. * Sets positionIterations of the impostor
  55979. * @param impostor impostor to set position on
  55980. * @param positionIterations positionIterations value
  55981. */
  55982. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55983. /**
  55984. * Append an anchor to a cloth object
  55985. * @param impostor is the cloth impostor to add anchor to
  55986. * @param otherImpostor is the rigid impostor to anchor to
  55987. * @param width ratio across width from 0 to 1
  55988. * @param height ratio up height from 0 to 1
  55989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55990. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55991. */
  55992. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55993. /**
  55994. * Append an hook to a rope object
  55995. * @param impostor is the rope impostor to add hook to
  55996. * @param otherImpostor is the rigid impostor to hook to
  55997. * @param length ratio along the rope from 0 to 1
  55998. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56000. */
  56001. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56002. /**
  56003. * Sleeps the physics body and stops it from being active
  56004. * @param impostor impostor to sleep
  56005. */
  56006. sleepBody(impostor: PhysicsImpostor): void;
  56007. /**
  56008. * Activates the physics body
  56009. * @param impostor impostor to activate
  56010. */
  56011. wakeUpBody(impostor: PhysicsImpostor): void;
  56012. /**
  56013. * Updates the distance parameters of the joint
  56014. * @param joint joint to update
  56015. * @param maxDistance maximum distance of the joint
  56016. * @param minDistance minimum distance of the joint
  56017. */
  56018. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56019. /**
  56020. * Sets a motor on the joint
  56021. * @param joint joint to set motor on
  56022. * @param speed speed of the motor
  56023. * @param maxForce maximum force of the motor
  56024. * @param motorIndex index of the motor
  56025. */
  56026. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56027. /**
  56028. * Sets the motors limit
  56029. * @param joint joint to set limit on
  56030. * @param upperLimit upper limit
  56031. * @param lowerLimit lower limit
  56032. */
  56033. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56034. /**
  56035. * Syncs the position and rotation of a mesh with the impostor
  56036. * @param mesh mesh to sync
  56037. * @param impostor impostor to update the mesh with
  56038. */
  56039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56040. /**
  56041. * Gets the radius of the impostor
  56042. * @param impostor impostor to get radius from
  56043. * @returns the radius
  56044. */
  56045. getRadius(impostor: PhysicsImpostor): number;
  56046. /**
  56047. * Gets the box size of the impostor
  56048. * @param impostor impostor to get box size from
  56049. * @param result the resulting box size
  56050. */
  56051. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56052. /**
  56053. * Disposes of the impostor
  56054. */
  56055. dispose(): void;
  56056. /**
  56057. * Does a raycast in the physics world
  56058. * @param from when should the ray start?
  56059. * @param to when should the ray end?
  56060. * @returns PhysicsRaycastResult
  56061. */
  56062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56063. }
  56064. }
  56065. declare module BABYLON {
  56066. interface AbstractScene {
  56067. /**
  56068. * The list of reflection probes added to the scene
  56069. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56070. */
  56071. reflectionProbes: Array<ReflectionProbe>;
  56072. /**
  56073. * Removes the given reflection probe from this scene.
  56074. * @param toRemove The reflection probe to remove
  56075. * @returns The index of the removed reflection probe
  56076. */
  56077. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56078. /**
  56079. * Adds the given reflection probe to this scene.
  56080. * @param newReflectionProbe The reflection probe to add
  56081. */
  56082. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56083. }
  56084. /**
  56085. * Class used to generate realtime reflection / refraction cube textures
  56086. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56087. */
  56088. export class ReflectionProbe {
  56089. /** defines the name of the probe */
  56090. name: string;
  56091. private _scene;
  56092. private _renderTargetTexture;
  56093. private _projectionMatrix;
  56094. private _viewMatrix;
  56095. private _target;
  56096. private _add;
  56097. private _attachedMesh;
  56098. private _invertYAxis;
  56099. /** Gets or sets probe position (center of the cube map) */
  56100. position: Vector3;
  56101. /**
  56102. * Creates a new reflection probe
  56103. * @param name defines the name of the probe
  56104. * @param size defines the texture resolution (for each face)
  56105. * @param scene defines the hosting scene
  56106. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56107. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56108. */
  56109. constructor(
  56110. /** defines the name of the probe */
  56111. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56112. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56113. get samples(): number;
  56114. set samples(value: number);
  56115. /** Gets or sets the refresh rate to use (on every frame by default) */
  56116. get refreshRate(): number;
  56117. set refreshRate(value: number);
  56118. /**
  56119. * Gets the hosting scene
  56120. * @returns a Scene
  56121. */
  56122. getScene(): Scene;
  56123. /** Gets the internal CubeTexture used to render to */
  56124. get cubeTexture(): RenderTargetTexture;
  56125. /** Gets the list of meshes to render */
  56126. get renderList(): Nullable<AbstractMesh[]>;
  56127. /**
  56128. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56129. * @param mesh defines the mesh to attach to
  56130. */
  56131. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56132. /**
  56133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56134. * @param renderingGroupId The rendering group id corresponding to its index
  56135. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56136. */
  56137. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56138. /**
  56139. * Clean all associated resources
  56140. */
  56141. dispose(): void;
  56142. /**
  56143. * Converts the reflection probe information to a readable string for debug purpose.
  56144. * @param fullDetails Supports for multiple levels of logging within scene loading
  56145. * @returns the human readable reflection probe info
  56146. */
  56147. toString(fullDetails?: boolean): string;
  56148. /**
  56149. * Get the class name of the relfection probe.
  56150. * @returns "ReflectionProbe"
  56151. */
  56152. getClassName(): string;
  56153. /**
  56154. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56155. * @returns The JSON representation of the texture
  56156. */
  56157. serialize(): any;
  56158. /**
  56159. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56160. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56161. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56162. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56163. * @returns The parsed reflection probe if successful
  56164. */
  56165. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56166. }
  56167. }
  56168. declare module BABYLON {
  56169. /** @hidden */
  56170. export var _BabylonLoaderRegistered: boolean;
  56171. /**
  56172. * Helps setting up some configuration for the babylon file loader.
  56173. */
  56174. export class BabylonFileLoaderConfiguration {
  56175. /**
  56176. * The loader does not allow injecting custom physix engine into the plugins.
  56177. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56178. * So you could set this variable to your engine import to make it work.
  56179. */
  56180. static LoaderInjectedPhysicsEngine: any;
  56181. }
  56182. }
  56183. declare module BABYLON {
  56184. /**
  56185. * The Physically based simple base material of BJS.
  56186. *
  56187. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56188. * It is used as the base class for both the specGloss and metalRough conventions.
  56189. */
  56190. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56191. /**
  56192. * Number of Simultaneous lights allowed on the material.
  56193. */
  56194. maxSimultaneousLights: number;
  56195. /**
  56196. * If sets to true, disables all the lights affecting the material.
  56197. */
  56198. disableLighting: boolean;
  56199. /**
  56200. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56201. */
  56202. environmentTexture: BaseTexture;
  56203. /**
  56204. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56205. */
  56206. invertNormalMapX: boolean;
  56207. /**
  56208. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56209. */
  56210. invertNormalMapY: boolean;
  56211. /**
  56212. * Normal map used in the model.
  56213. */
  56214. normalTexture: BaseTexture;
  56215. /**
  56216. * Emissivie color used to self-illuminate the model.
  56217. */
  56218. emissiveColor: Color3;
  56219. /**
  56220. * Emissivie texture used to self-illuminate the model.
  56221. */
  56222. emissiveTexture: BaseTexture;
  56223. /**
  56224. * Occlusion Channel Strenght.
  56225. */
  56226. occlusionStrength: number;
  56227. /**
  56228. * Occlusion Texture of the material (adding extra occlusion effects).
  56229. */
  56230. occlusionTexture: BaseTexture;
  56231. /**
  56232. * Defines the alpha limits in alpha test mode.
  56233. */
  56234. alphaCutOff: number;
  56235. /**
  56236. * Gets the current double sided mode.
  56237. */
  56238. get doubleSided(): boolean;
  56239. /**
  56240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56241. */
  56242. set doubleSided(value: boolean);
  56243. /**
  56244. * Stores the pre-calculated light information of a mesh in a texture.
  56245. */
  56246. lightmapTexture: BaseTexture;
  56247. /**
  56248. * If true, the light map contains occlusion information instead of lighting info.
  56249. */
  56250. useLightmapAsShadowmap: boolean;
  56251. /**
  56252. * Instantiates a new PBRMaterial instance.
  56253. *
  56254. * @param name The material name
  56255. * @param scene The scene the material will be use in.
  56256. */
  56257. constructor(name: string, scene: Scene);
  56258. getClassName(): string;
  56259. }
  56260. }
  56261. declare module BABYLON {
  56262. /**
  56263. * The PBR material of BJS following the metal roughness convention.
  56264. *
  56265. * This fits to the PBR convention in the GLTF definition:
  56266. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56267. */
  56268. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56269. /**
  56270. * The base color has two different interpretations depending on the value of metalness.
  56271. * When the material is a metal, the base color is the specific measured reflectance value
  56272. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56273. * of the material.
  56274. */
  56275. baseColor: Color3;
  56276. /**
  56277. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56278. * well as opacity information in the alpha channel.
  56279. */
  56280. baseTexture: BaseTexture;
  56281. /**
  56282. * Specifies the metallic scalar value of the material.
  56283. * Can also be used to scale the metalness values of the metallic texture.
  56284. */
  56285. metallic: number;
  56286. /**
  56287. * Specifies the roughness scalar value of the material.
  56288. * Can also be used to scale the roughness values of the metallic texture.
  56289. */
  56290. roughness: number;
  56291. /**
  56292. * Texture containing both the metallic value in the B channel and the
  56293. * roughness value in the G channel to keep better precision.
  56294. */
  56295. metallicRoughnessTexture: BaseTexture;
  56296. /**
  56297. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56298. *
  56299. * @param name The material name
  56300. * @param scene The scene the material will be use in.
  56301. */
  56302. constructor(name: string, scene: Scene);
  56303. /**
  56304. * Return the currrent class name of the material.
  56305. */
  56306. getClassName(): string;
  56307. /**
  56308. * Makes a duplicate of the current material.
  56309. * @param name - name to use for the new material.
  56310. */
  56311. clone(name: string): PBRMetallicRoughnessMaterial;
  56312. /**
  56313. * Serialize the material to a parsable JSON object.
  56314. */
  56315. serialize(): any;
  56316. /**
  56317. * Parses a JSON object correponding to the serialize function.
  56318. */
  56319. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56320. }
  56321. }
  56322. declare module BABYLON {
  56323. /**
  56324. * The PBR material of BJS following the specular glossiness convention.
  56325. *
  56326. * This fits to the PBR convention in the GLTF definition:
  56327. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56328. */
  56329. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56330. /**
  56331. * Specifies the diffuse color of the material.
  56332. */
  56333. diffuseColor: Color3;
  56334. /**
  56335. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56336. * channel.
  56337. */
  56338. diffuseTexture: BaseTexture;
  56339. /**
  56340. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56341. */
  56342. specularColor: Color3;
  56343. /**
  56344. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56345. */
  56346. glossiness: number;
  56347. /**
  56348. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56349. */
  56350. specularGlossinessTexture: BaseTexture;
  56351. /**
  56352. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56353. *
  56354. * @param name The material name
  56355. * @param scene The scene the material will be use in.
  56356. */
  56357. constructor(name: string, scene: Scene);
  56358. /**
  56359. * Return the currrent class name of the material.
  56360. */
  56361. getClassName(): string;
  56362. /**
  56363. * Makes a duplicate of the current material.
  56364. * @param name - name to use for the new material.
  56365. */
  56366. clone(name: string): PBRSpecularGlossinessMaterial;
  56367. /**
  56368. * Serialize the material to a parsable JSON object.
  56369. */
  56370. serialize(): any;
  56371. /**
  56372. * Parses a JSON object correponding to the serialize function.
  56373. */
  56374. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56375. }
  56376. }
  56377. declare module BABYLON {
  56378. /**
  56379. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56380. * It can help converting any input color in a desired output one. This can then be used to create effects
  56381. * from sepia, black and white to sixties or futuristic rendering...
  56382. *
  56383. * The only supported format is currently 3dl.
  56384. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56385. */
  56386. export class ColorGradingTexture extends BaseTexture {
  56387. /**
  56388. * The current texture matrix. (will always be identity in color grading texture)
  56389. */
  56390. private _textureMatrix;
  56391. /**
  56392. * The texture URL.
  56393. */
  56394. url: string;
  56395. /**
  56396. * Empty line regex stored for GC.
  56397. */
  56398. private static _noneEmptyLineRegex;
  56399. private _engine;
  56400. /**
  56401. * Instantiates a ColorGradingTexture from the following parameters.
  56402. *
  56403. * @param url The location of the color gradind data (currently only supporting 3dl)
  56404. * @param scene The scene the texture will be used in
  56405. */
  56406. constructor(url: string, scene: Scene);
  56407. /**
  56408. * Returns the texture matrix used in most of the material.
  56409. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56410. */
  56411. getTextureMatrix(): Matrix;
  56412. /**
  56413. * Occurs when the file being loaded is a .3dl LUT file.
  56414. */
  56415. private load3dlTexture;
  56416. /**
  56417. * Starts the loading process of the texture.
  56418. */
  56419. private loadTexture;
  56420. /**
  56421. * Clones the color gradind texture.
  56422. */
  56423. clone(): ColorGradingTexture;
  56424. /**
  56425. * Called during delayed load for textures.
  56426. */
  56427. delayLoad(): void;
  56428. /**
  56429. * Parses a color grading texture serialized by Babylon.
  56430. * @param parsedTexture The texture information being parsedTexture
  56431. * @param scene The scene to load the texture in
  56432. * @param rootUrl The root url of the data assets to load
  56433. * @return A color gradind texture
  56434. */
  56435. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56436. /**
  56437. * Serializes the LUT texture to json format.
  56438. */
  56439. serialize(): any;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /**
  56444. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56445. */
  56446. export class EquiRectangularCubeTexture extends BaseTexture {
  56447. /** The six faces of the cube. */
  56448. private static _FacesMapping;
  56449. private _noMipmap;
  56450. private _onLoad;
  56451. private _onError;
  56452. /** The size of the cubemap. */
  56453. private _size;
  56454. /** The buffer of the image. */
  56455. private _buffer;
  56456. /** The width of the input image. */
  56457. private _width;
  56458. /** The height of the input image. */
  56459. private _height;
  56460. /** The URL to the image. */
  56461. url: string;
  56462. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56463. coordinatesMode: number;
  56464. /**
  56465. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56466. * @param url The location of the image
  56467. * @param scene The scene the texture will be used in
  56468. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56469. * @param noMipmap Forces to not generate the mipmap if true
  56470. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56471. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56472. * @param onLoad — defines a callback called when texture is loaded
  56473. * @param onError — defines a callback called if there is an error
  56474. */
  56475. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56476. /**
  56477. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56478. */
  56479. private loadImage;
  56480. /**
  56481. * Convert the image buffer into a cubemap and create a CubeTexture.
  56482. */
  56483. private loadTexture;
  56484. /**
  56485. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56486. * @param buffer The ArrayBuffer that should be converted.
  56487. * @returns The buffer as Float32Array.
  56488. */
  56489. private getFloat32ArrayFromArrayBuffer;
  56490. /**
  56491. * Get the current class name of the texture useful for serialization or dynamic coding.
  56492. * @returns "EquiRectangularCubeTexture"
  56493. */
  56494. getClassName(): string;
  56495. /**
  56496. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56497. * @returns A clone of the current EquiRectangularCubeTexture.
  56498. */
  56499. clone(): EquiRectangularCubeTexture;
  56500. }
  56501. }
  56502. declare module BABYLON {
  56503. /**
  56504. * Based on jsTGALoader - Javascript loader for TGA file
  56505. * By Vincent Thibault
  56506. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56507. */
  56508. export class TGATools {
  56509. private static _TYPE_INDEXED;
  56510. private static _TYPE_RGB;
  56511. private static _TYPE_GREY;
  56512. private static _TYPE_RLE_INDEXED;
  56513. private static _TYPE_RLE_RGB;
  56514. private static _TYPE_RLE_GREY;
  56515. private static _ORIGIN_MASK;
  56516. private static _ORIGIN_SHIFT;
  56517. private static _ORIGIN_BL;
  56518. private static _ORIGIN_BR;
  56519. private static _ORIGIN_UL;
  56520. private static _ORIGIN_UR;
  56521. /**
  56522. * Gets the header of a TGA file
  56523. * @param data defines the TGA data
  56524. * @returns the header
  56525. */
  56526. static GetTGAHeader(data: Uint8Array): any;
  56527. /**
  56528. * Uploads TGA content to a Babylon Texture
  56529. * @hidden
  56530. */
  56531. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56532. /** @hidden */
  56533. 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;
  56534. /** @hidden */
  56535. 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;
  56536. /** @hidden */
  56537. 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;
  56538. /** @hidden */
  56539. 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;
  56540. /** @hidden */
  56541. 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;
  56542. /** @hidden */
  56543. 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;
  56544. }
  56545. }
  56546. declare module BABYLON {
  56547. /**
  56548. * Implementation of the TGA Texture Loader.
  56549. * @hidden
  56550. */
  56551. export class _TGATextureLoader implements IInternalTextureLoader {
  56552. /**
  56553. * Defines wether the loader supports cascade loading the different faces.
  56554. */
  56555. readonly supportCascades: boolean;
  56556. /**
  56557. * This returns if the loader support the current file information.
  56558. * @param extension defines the file extension of the file being loaded
  56559. * @returns true if the loader can load the specified file
  56560. */
  56561. canLoad(extension: string): boolean;
  56562. /**
  56563. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56564. * @param data contains the texture data
  56565. * @param texture defines the BabylonJS internal texture
  56566. * @param createPolynomials will be true if polynomials have been requested
  56567. * @param onLoad defines the callback to trigger once the texture is ready
  56568. * @param onError defines the callback to trigger in case of error
  56569. */
  56570. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56571. /**
  56572. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56573. * @param data contains the texture data
  56574. * @param texture defines the BabylonJS internal texture
  56575. * @param callback defines the method to call once ready to upload
  56576. */
  56577. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56578. }
  56579. }
  56580. declare module BABYLON {
  56581. /**
  56582. * Info about the .basis files
  56583. */
  56584. class BasisFileInfo {
  56585. /**
  56586. * If the file has alpha
  56587. */
  56588. hasAlpha: boolean;
  56589. /**
  56590. * Info about each image of the basis file
  56591. */
  56592. images: Array<{
  56593. levels: Array<{
  56594. width: number;
  56595. height: number;
  56596. transcodedPixels: ArrayBufferView;
  56597. }>;
  56598. }>;
  56599. }
  56600. /**
  56601. * Result of transcoding a basis file
  56602. */
  56603. class TranscodeResult {
  56604. /**
  56605. * Info about the .basis file
  56606. */
  56607. fileInfo: BasisFileInfo;
  56608. /**
  56609. * Format to use when loading the file
  56610. */
  56611. format: number;
  56612. }
  56613. /**
  56614. * Configuration options for the Basis transcoder
  56615. */
  56616. export class BasisTranscodeConfiguration {
  56617. /**
  56618. * Supported compression formats used to determine the supported output format of the transcoder
  56619. */
  56620. supportedCompressionFormats?: {
  56621. /**
  56622. * etc1 compression format
  56623. */
  56624. etc1?: boolean;
  56625. /**
  56626. * s3tc compression format
  56627. */
  56628. s3tc?: boolean;
  56629. /**
  56630. * pvrtc compression format
  56631. */
  56632. pvrtc?: boolean;
  56633. /**
  56634. * etc2 compression format
  56635. */
  56636. etc2?: boolean;
  56637. };
  56638. /**
  56639. * If mipmap levels should be loaded for transcoded images (Default: true)
  56640. */
  56641. loadMipmapLevels?: boolean;
  56642. /**
  56643. * Index of a single image to load (Default: all images)
  56644. */
  56645. loadSingleImage?: number;
  56646. }
  56647. /**
  56648. * Used to load .Basis files
  56649. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56650. */
  56651. export class BasisTools {
  56652. private static _IgnoreSupportedFormats;
  56653. /**
  56654. * URL to use when loading the basis transcoder
  56655. */
  56656. static JSModuleURL: string;
  56657. /**
  56658. * URL to use when loading the wasm module for the transcoder
  56659. */
  56660. static WasmModuleURL: string;
  56661. /**
  56662. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56663. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56664. * @returns internal format corresponding to the Basis format
  56665. */
  56666. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56667. private static _WorkerPromise;
  56668. private static _Worker;
  56669. private static _actionId;
  56670. private static _CreateWorkerAsync;
  56671. /**
  56672. * Transcodes a loaded image file to compressed pixel data
  56673. * @param data image data to transcode
  56674. * @param config configuration options for the transcoding
  56675. * @returns a promise resulting in the transcoded image
  56676. */
  56677. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56678. /**
  56679. * Loads a texture from the transcode result
  56680. * @param texture texture load to
  56681. * @param transcodeResult the result of transcoding the basis file to load from
  56682. */
  56683. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56684. }
  56685. }
  56686. declare module BABYLON {
  56687. /**
  56688. * Loader for .basis file format
  56689. */
  56690. export class _BasisTextureLoader implements IInternalTextureLoader {
  56691. /**
  56692. * Defines whether the loader supports cascade loading the different faces.
  56693. */
  56694. readonly supportCascades: boolean;
  56695. /**
  56696. * This returns if the loader support the current file information.
  56697. * @param extension defines the file extension of the file being loaded
  56698. * @returns true if the loader can load the specified file
  56699. */
  56700. canLoad(extension: string): boolean;
  56701. /**
  56702. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56703. * @param data contains the texture data
  56704. * @param texture defines the BabylonJS internal texture
  56705. * @param createPolynomials will be true if polynomials have been requested
  56706. * @param onLoad defines the callback to trigger once the texture is ready
  56707. * @param onError defines the callback to trigger in case of error
  56708. */
  56709. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56710. /**
  56711. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56712. * @param data contains the texture data
  56713. * @param texture defines the BabylonJS internal texture
  56714. * @param callback defines the method to call once ready to upload
  56715. */
  56716. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56717. }
  56718. }
  56719. declare module BABYLON {
  56720. /**
  56721. * 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.
  56722. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56724. */
  56725. export class CustomProceduralTexture extends ProceduralTexture {
  56726. private _animate;
  56727. private _time;
  56728. private _config;
  56729. private _texturePath;
  56730. /**
  56731. * Instantiates a new Custom Procedural Texture.
  56732. * 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.
  56733. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56734. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56735. * @param name Define the name of the texture
  56736. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56737. * @param size Define the size of the texture to create
  56738. * @param scene Define the scene the texture belongs to
  56739. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56740. * @param generateMipMaps Define if the texture should creates mip maps or not
  56741. */
  56742. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56743. private _loadJson;
  56744. /**
  56745. * Is the texture ready to be used ? (rendered at least once)
  56746. * @returns true if ready, otherwise, false.
  56747. */
  56748. isReady(): boolean;
  56749. /**
  56750. * Render the texture to its associated render target.
  56751. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56752. */
  56753. render(useCameraPostProcess?: boolean): void;
  56754. /**
  56755. * Update the list of dependant textures samplers in the shader.
  56756. */
  56757. updateTextures(): void;
  56758. /**
  56759. * Update the uniform values of the procedural texture in the shader.
  56760. */
  56761. updateShaderUniforms(): void;
  56762. /**
  56763. * Define if the texture animates or not.
  56764. */
  56765. get animate(): boolean;
  56766. set animate(value: boolean);
  56767. }
  56768. }
  56769. declare module BABYLON {
  56770. /** @hidden */
  56771. export var noisePixelShader: {
  56772. name: string;
  56773. shader: string;
  56774. };
  56775. }
  56776. declare module BABYLON {
  56777. /**
  56778. * Class used to generate noise procedural textures
  56779. */
  56780. export class NoiseProceduralTexture extends ProceduralTexture {
  56781. private _time;
  56782. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56783. brightness: number;
  56784. /** Defines the number of octaves to process */
  56785. octaves: number;
  56786. /** Defines the level of persistence (0.8 by default) */
  56787. persistence: number;
  56788. /** Gets or sets animation speed factor (default is 1) */
  56789. animationSpeedFactor: number;
  56790. /**
  56791. * Creates a new NoiseProceduralTexture
  56792. * @param name defines the name fo the texture
  56793. * @param size defines the size of the texture (default is 256)
  56794. * @param scene defines the hosting scene
  56795. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56796. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56797. */
  56798. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56799. private _updateShaderUniforms;
  56800. protected _getDefines(): string;
  56801. /** Generate the current state of the procedural texture */
  56802. render(useCameraPostProcess?: boolean): void;
  56803. /**
  56804. * Serializes this noise procedural texture
  56805. * @returns a serialized noise procedural texture object
  56806. */
  56807. serialize(): any;
  56808. /**
  56809. * Clone the texture.
  56810. * @returns the cloned texture
  56811. */
  56812. clone(): NoiseProceduralTexture;
  56813. /**
  56814. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56815. * @param parsedTexture defines parsed texture data
  56816. * @param scene defines the current scene
  56817. * @param rootUrl defines the root URL containing noise procedural texture information
  56818. * @returns a parsed NoiseProceduralTexture
  56819. */
  56820. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56821. }
  56822. }
  56823. declare module BABYLON {
  56824. /**
  56825. * Raw cube texture where the raw buffers are passed in
  56826. */
  56827. export class RawCubeTexture extends CubeTexture {
  56828. /**
  56829. * Creates a cube texture where the raw buffers are passed in.
  56830. * @param scene defines the scene the texture is attached to
  56831. * @param data defines the array of data to use to create each face
  56832. * @param size defines the size of the textures
  56833. * @param format defines the format of the data
  56834. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56835. * @param generateMipMaps defines if the engine should generate the mip levels
  56836. * @param invertY defines if data must be stored with Y axis inverted
  56837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56838. * @param compression defines the compression used (null by default)
  56839. */
  56840. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56841. /**
  56842. * Updates the raw cube texture.
  56843. * @param data defines the data to store
  56844. * @param format defines the data format
  56845. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56846. * @param invertY defines if data must be stored with Y axis inverted
  56847. * @param compression defines the compression used (null by default)
  56848. * @param level defines which level of the texture to update
  56849. */
  56850. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56851. /**
  56852. * Updates a raw cube texture with RGBD encoded data.
  56853. * @param data defines the array of data [mipmap][face] to use to create each face
  56854. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56857. * @returns a promsie that resolves when the operation is complete
  56858. */
  56859. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56860. /**
  56861. * Clones the raw cube texture.
  56862. * @return a new cube texture
  56863. */
  56864. clone(): CubeTexture;
  56865. /** @hidden */
  56866. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56867. }
  56868. }
  56869. declare module BABYLON {
  56870. /**
  56871. * Class used to store 3D textures containing user data
  56872. */
  56873. export class RawTexture3D extends Texture {
  56874. /** Gets or sets the texture format to use */
  56875. format: number;
  56876. private _engine;
  56877. /**
  56878. * Create a new RawTexture3D
  56879. * @param data defines the data of the texture
  56880. * @param width defines the width of the texture
  56881. * @param height defines the height of the texture
  56882. * @param depth defines the depth of the texture
  56883. * @param format defines the texture format to use
  56884. * @param scene defines the hosting scene
  56885. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56886. * @param invertY defines if texture must be stored with Y axis inverted
  56887. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56888. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56889. */
  56890. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56891. /** Gets or sets the texture format to use */
  56892. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56893. /**
  56894. * Update the texture with new data
  56895. * @param data defines the data to store in the texture
  56896. */
  56897. update(data: ArrayBufferView): void;
  56898. }
  56899. }
  56900. declare module BABYLON {
  56901. /**
  56902. * Class used to store 2D array textures containing user data
  56903. */
  56904. export class RawTexture2DArray extends Texture {
  56905. /** Gets or sets the texture format to use */
  56906. format: number;
  56907. private _engine;
  56908. /**
  56909. * Create a new RawTexture2DArray
  56910. * @param data defines the data of the texture
  56911. * @param width defines the width of the texture
  56912. * @param height defines the height of the texture
  56913. * @param depth defines the number of layers of the texture
  56914. * @param format defines the texture format to use
  56915. * @param scene defines the hosting scene
  56916. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56917. * @param invertY defines if texture must be stored with Y axis inverted
  56918. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56919. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56920. */
  56921. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56922. /** Gets or sets the texture format to use */
  56923. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56924. /**
  56925. * Update the texture with new data
  56926. * @param data defines the data to store in the texture
  56927. */
  56928. update(data: ArrayBufferView): void;
  56929. }
  56930. }
  56931. declare module BABYLON {
  56932. /**
  56933. * Creates a refraction texture used by refraction channel of the standard material.
  56934. * It is like a mirror but to see through a material.
  56935. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56936. */
  56937. export class RefractionTexture extends RenderTargetTexture {
  56938. /**
  56939. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56940. * 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.
  56941. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56942. */
  56943. refractionPlane: Plane;
  56944. /**
  56945. * Define how deep under the surface we should see.
  56946. */
  56947. depth: number;
  56948. /**
  56949. * Creates a refraction texture used by refraction channel of the standard material.
  56950. * It is like a mirror but to see through a material.
  56951. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56952. * @param name Define the texture name
  56953. * @param size Define the size of the underlying texture
  56954. * @param scene Define the scene the refraction belongs to
  56955. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56956. */
  56957. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56958. /**
  56959. * Clone the refraction texture.
  56960. * @returns the cloned texture
  56961. */
  56962. clone(): RefractionTexture;
  56963. /**
  56964. * Serialize the texture to a JSON representation you could use in Parse later on
  56965. * @returns the serialized JSON representation
  56966. */
  56967. serialize(): any;
  56968. }
  56969. }
  56970. declare module BABYLON {
  56971. /**
  56972. * Defines the options related to the creation of an HtmlElementTexture
  56973. */
  56974. export interface IHtmlElementTextureOptions {
  56975. /**
  56976. * Defines wether mip maps should be created or not.
  56977. */
  56978. generateMipMaps?: boolean;
  56979. /**
  56980. * Defines the sampling mode of the texture.
  56981. */
  56982. samplingMode?: number;
  56983. /**
  56984. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56985. */
  56986. engine: Nullable<ThinEngine>;
  56987. /**
  56988. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56989. */
  56990. scene: Nullable<Scene>;
  56991. }
  56992. /**
  56993. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56994. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56995. * is automatically managed.
  56996. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56997. * in your application.
  56998. *
  56999. * As the update is not automatic, you need to call them manually.
  57000. */
  57001. export class HtmlElementTexture extends BaseTexture {
  57002. /**
  57003. * The texture URL.
  57004. */
  57005. element: HTMLVideoElement | HTMLCanvasElement;
  57006. private static readonly DefaultOptions;
  57007. private _textureMatrix;
  57008. private _engine;
  57009. private _isVideo;
  57010. private _generateMipMaps;
  57011. private _samplingMode;
  57012. /**
  57013. * Instantiates a HtmlElementTexture from the following parameters.
  57014. *
  57015. * @param name Defines the name of the texture
  57016. * @param element Defines the video or canvas the texture is filled with
  57017. * @param options Defines the other none mandatory texture creation options
  57018. */
  57019. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57020. private _createInternalTexture;
  57021. /**
  57022. * Returns the texture matrix used in most of the material.
  57023. */
  57024. getTextureMatrix(): Matrix;
  57025. /**
  57026. * Updates the content of the texture.
  57027. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57028. */
  57029. update(invertY?: Nullable<boolean>): void;
  57030. }
  57031. }
  57032. declare module BABYLON {
  57033. /**
  57034. * Defines the basic options interface of a TexturePacker Frame
  57035. */
  57036. export interface ITexturePackerFrame {
  57037. /**
  57038. * The frame ID
  57039. */
  57040. id: number;
  57041. /**
  57042. * The frames Scale
  57043. */
  57044. scale: Vector2;
  57045. /**
  57046. * The Frames offset
  57047. */
  57048. offset: Vector2;
  57049. }
  57050. /**
  57051. * This is a support class for frame Data on texture packer sets.
  57052. */
  57053. export class TexturePackerFrame implements ITexturePackerFrame {
  57054. /**
  57055. * The frame ID
  57056. */
  57057. id: number;
  57058. /**
  57059. * The frames Scale
  57060. */
  57061. scale: Vector2;
  57062. /**
  57063. * The Frames offset
  57064. */
  57065. offset: Vector2;
  57066. /**
  57067. * Initializes a texture package frame.
  57068. * @param id The numerical frame identifier
  57069. * @param scale Scalar Vector2 for UV frame
  57070. * @param offset Vector2 for the frame position in UV units.
  57071. * @returns TexturePackerFrame
  57072. */
  57073. constructor(id: number, scale: Vector2, offset: Vector2);
  57074. }
  57075. }
  57076. declare module BABYLON {
  57077. /**
  57078. * Defines the basic options interface of a TexturePacker
  57079. */
  57080. export interface ITexturePackerOptions {
  57081. /**
  57082. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57083. */
  57084. map?: string[];
  57085. /**
  57086. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57087. */
  57088. uvsIn?: string;
  57089. /**
  57090. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57091. */
  57092. uvsOut?: string;
  57093. /**
  57094. * number representing the layout style. Defaults to LAYOUT_STRIP
  57095. */
  57096. layout?: number;
  57097. /**
  57098. * number of columns if using custom column count layout(2). This defaults to 4.
  57099. */
  57100. colnum?: number;
  57101. /**
  57102. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57103. */
  57104. updateInputMeshes?: boolean;
  57105. /**
  57106. * boolean flag to dispose all the source textures. Defaults to true.
  57107. */
  57108. disposeSources?: boolean;
  57109. /**
  57110. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57111. */
  57112. fillBlanks?: boolean;
  57113. /**
  57114. * string value representing the context fill style color. Defaults to 'black'.
  57115. */
  57116. customFillColor?: string;
  57117. /**
  57118. * Width and Height Value of each Frame in the TexturePacker Sets
  57119. */
  57120. frameSize?: number;
  57121. /**
  57122. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57123. */
  57124. paddingRatio?: number;
  57125. /**
  57126. * Number that declares the fill method for the padding gutter.
  57127. */
  57128. paddingMode?: number;
  57129. /**
  57130. * If in SUBUV_COLOR padding mode what color to use.
  57131. */
  57132. paddingColor?: Color3 | Color4;
  57133. }
  57134. /**
  57135. * Defines the basic interface of a TexturePacker JSON File
  57136. */
  57137. export interface ITexturePackerJSON {
  57138. /**
  57139. * The frame ID
  57140. */
  57141. name: string;
  57142. /**
  57143. * The base64 channel data
  57144. */
  57145. sets: any;
  57146. /**
  57147. * The options of the Packer
  57148. */
  57149. options: ITexturePackerOptions;
  57150. /**
  57151. * The frame data of the Packer
  57152. */
  57153. frames: Array<number>;
  57154. }
  57155. /**
  57156. * This is a support class that generates a series of packed texture sets.
  57157. * @see https://doc.babylonjs.com/babylon101/materials
  57158. */
  57159. export class TexturePacker {
  57160. /** Packer Layout Constant 0 */
  57161. static readonly LAYOUT_STRIP: number;
  57162. /** Packer Layout Constant 1 */
  57163. static readonly LAYOUT_POWER2: number;
  57164. /** Packer Layout Constant 2 */
  57165. static readonly LAYOUT_COLNUM: number;
  57166. /** Packer Layout Constant 0 */
  57167. static readonly SUBUV_WRAP: number;
  57168. /** Packer Layout Constant 1 */
  57169. static readonly SUBUV_EXTEND: number;
  57170. /** Packer Layout Constant 2 */
  57171. static readonly SUBUV_COLOR: number;
  57172. /** The Name of the Texture Package */
  57173. name: string;
  57174. /** The scene scope of the TexturePacker */
  57175. scene: Scene;
  57176. /** The Meshes to target */
  57177. meshes: AbstractMesh[];
  57178. /** Arguments passed with the Constructor */
  57179. options: ITexturePackerOptions;
  57180. /** The promise that is started upon initialization */
  57181. promise: Nullable<Promise<TexturePacker | string>>;
  57182. /** The Container object for the channel sets that are generated */
  57183. sets: object;
  57184. /** The Container array for the frames that are generated */
  57185. frames: TexturePackerFrame[];
  57186. /** The expected number of textures the system is parsing. */
  57187. private _expecting;
  57188. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57189. private _paddingValue;
  57190. /**
  57191. * Initializes a texture package series from an array of meshes or a single mesh.
  57192. * @param name The name of the package
  57193. * @param meshes The target meshes to compose the package from
  57194. * @param options The arguments that texture packer should follow while building.
  57195. * @param scene The scene which the textures are scoped to.
  57196. * @returns TexturePacker
  57197. */
  57198. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57199. /**
  57200. * Starts the package process
  57201. * @param resolve The promises resolution function
  57202. * @returns TexturePacker
  57203. */
  57204. private _createFrames;
  57205. /**
  57206. * Calculates the Size of the Channel Sets
  57207. * @returns Vector2
  57208. */
  57209. private _calculateSize;
  57210. /**
  57211. * Calculates the UV data for the frames.
  57212. * @param baseSize the base frameSize
  57213. * @param padding the base frame padding
  57214. * @param dtSize size of the Dynamic Texture for that channel
  57215. * @param dtUnits is 1/dtSize
  57216. * @param update flag to update the input meshes
  57217. */
  57218. private _calculateMeshUVFrames;
  57219. /**
  57220. * Calculates the frames Offset.
  57221. * @param index of the frame
  57222. * @returns Vector2
  57223. */
  57224. private _getFrameOffset;
  57225. /**
  57226. * Updates a Mesh to the frame data
  57227. * @param mesh that is the target
  57228. * @param frameID or the frame index
  57229. */
  57230. private _updateMeshUV;
  57231. /**
  57232. * Updates a Meshes materials to use the texture packer channels
  57233. * @param m is the mesh to target
  57234. * @param force all channels on the packer to be set.
  57235. */
  57236. private _updateTextureReferences;
  57237. /**
  57238. * Public method to set a Mesh to a frame
  57239. * @param m that is the target
  57240. * @param frameID or the frame index
  57241. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57242. */
  57243. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57244. /**
  57245. * Starts the async promise to compile the texture packer.
  57246. * @returns Promise<void>
  57247. */
  57248. processAsync(): Promise<void>;
  57249. /**
  57250. * Disposes all textures associated with this packer
  57251. */
  57252. dispose(): void;
  57253. /**
  57254. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57255. * @param imageType is the image type to use.
  57256. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57257. */
  57258. download(imageType?: string, quality?: number): void;
  57259. /**
  57260. * Public method to load a texturePacker JSON file.
  57261. * @param data of the JSON file in string format.
  57262. */
  57263. updateFromJSON(data: string): void;
  57264. }
  57265. }
  57266. declare module BABYLON {
  57267. /**
  57268. * Enum used to define the target of a block
  57269. */
  57270. export enum NodeMaterialBlockTargets {
  57271. /** Vertex shader */
  57272. Vertex = 1,
  57273. /** Fragment shader */
  57274. Fragment = 2,
  57275. /** Neutral */
  57276. Neutral = 4,
  57277. /** Vertex and Fragment */
  57278. VertexAndFragment = 3
  57279. }
  57280. }
  57281. declare module BABYLON {
  57282. /**
  57283. * Defines the kind of connection point for node based material
  57284. */
  57285. export enum NodeMaterialBlockConnectionPointTypes {
  57286. /** Float */
  57287. Float = 1,
  57288. /** Int */
  57289. Int = 2,
  57290. /** Vector2 */
  57291. Vector2 = 4,
  57292. /** Vector3 */
  57293. Vector3 = 8,
  57294. /** Vector4 */
  57295. Vector4 = 16,
  57296. /** Color3 */
  57297. Color3 = 32,
  57298. /** Color4 */
  57299. Color4 = 64,
  57300. /** Matrix */
  57301. Matrix = 128,
  57302. /** Detect type based on connection */
  57303. AutoDetect = 1024,
  57304. /** Output type that will be defined by input type */
  57305. BasedOnInput = 2048
  57306. }
  57307. }
  57308. declare module BABYLON {
  57309. /**
  57310. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57311. */
  57312. export enum NodeMaterialBlockConnectionPointMode {
  57313. /** Value is an uniform */
  57314. Uniform = 0,
  57315. /** Value is a mesh attribute */
  57316. Attribute = 1,
  57317. /** Value is a varying between vertex and fragment shaders */
  57318. Varying = 2,
  57319. /** Mode is undefined */
  57320. Undefined = 3
  57321. }
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * Enum used to define system values e.g. values automatically provided by the system
  57326. */
  57327. export enum NodeMaterialSystemValues {
  57328. /** World */
  57329. World = 1,
  57330. /** View */
  57331. View = 2,
  57332. /** Projection */
  57333. Projection = 3,
  57334. /** ViewProjection */
  57335. ViewProjection = 4,
  57336. /** WorldView */
  57337. WorldView = 5,
  57338. /** WorldViewProjection */
  57339. WorldViewProjection = 6,
  57340. /** CameraPosition */
  57341. CameraPosition = 7,
  57342. /** Fog Color */
  57343. FogColor = 8,
  57344. /** Delta time */
  57345. DeltaTime = 9
  57346. }
  57347. }
  57348. declare module BABYLON {
  57349. /**
  57350. * Root class for all node material optimizers
  57351. */
  57352. export class NodeMaterialOptimizer {
  57353. /**
  57354. * Function used to optimize a NodeMaterial graph
  57355. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57356. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57357. */
  57358. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /**
  57363. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57364. */
  57365. export class TransformBlock extends NodeMaterialBlock {
  57366. /**
  57367. * Defines the value to use to complement W value to transform it to a Vector4
  57368. */
  57369. complementW: number;
  57370. /**
  57371. * Defines the value to use to complement z value to transform it to a Vector4
  57372. */
  57373. complementZ: number;
  57374. /**
  57375. * Creates a new TransformBlock
  57376. * @param name defines the block name
  57377. */
  57378. constructor(name: string);
  57379. /**
  57380. * Gets the current class name
  57381. * @returns the class name
  57382. */
  57383. getClassName(): string;
  57384. /**
  57385. * Gets the vector input
  57386. */
  57387. get vector(): NodeMaterialConnectionPoint;
  57388. /**
  57389. * Gets the output component
  57390. */
  57391. get output(): NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the xyz output component
  57394. */
  57395. get xyz(): NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the matrix transform input
  57398. */
  57399. get transform(): NodeMaterialConnectionPoint;
  57400. protected _buildBlock(state: NodeMaterialBuildState): this;
  57401. serialize(): any;
  57402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57403. protected _dumpPropertiesCode(): string;
  57404. }
  57405. }
  57406. declare module BABYLON {
  57407. /**
  57408. * Block used to output the vertex position
  57409. */
  57410. export class VertexOutputBlock extends NodeMaterialBlock {
  57411. /**
  57412. * Creates a new VertexOutputBlock
  57413. * @param name defines the block name
  57414. */
  57415. constructor(name: string);
  57416. /**
  57417. * Gets the current class name
  57418. * @returns the class name
  57419. */
  57420. getClassName(): string;
  57421. /**
  57422. * Gets the vector input component
  57423. */
  57424. get vector(): NodeMaterialConnectionPoint;
  57425. protected _buildBlock(state: NodeMaterialBuildState): this;
  57426. }
  57427. }
  57428. declare module BABYLON {
  57429. /**
  57430. * Block used to output the final color
  57431. */
  57432. export class FragmentOutputBlock extends NodeMaterialBlock {
  57433. /**
  57434. * Create a new FragmentOutputBlock
  57435. * @param name defines the block name
  57436. */
  57437. constructor(name: string);
  57438. /**
  57439. * Gets the current class name
  57440. * @returns the class name
  57441. */
  57442. getClassName(): string;
  57443. /**
  57444. * Gets the rgba input component
  57445. */
  57446. get rgba(): NodeMaterialConnectionPoint;
  57447. /**
  57448. * Gets the rgb input component
  57449. */
  57450. get rgb(): NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the a input component
  57453. */
  57454. get a(): NodeMaterialConnectionPoint;
  57455. protected _buildBlock(state: NodeMaterialBuildState): this;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Block used to read a reflection texture from a sampler
  57461. */
  57462. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57463. private _define3DName;
  57464. private _defineCubicName;
  57465. private _defineExplicitName;
  57466. private _defineProjectionName;
  57467. private _defineLocalCubicName;
  57468. private _defineSphericalName;
  57469. private _definePlanarName;
  57470. private _defineEquirectangularName;
  57471. private _defineMirroredEquirectangularFixedName;
  57472. private _defineEquirectangularFixedName;
  57473. private _defineSkyboxName;
  57474. private _cubeSamplerName;
  57475. private _2DSamplerName;
  57476. private _positionUVWName;
  57477. private _directionWName;
  57478. private _reflectionCoordsName;
  57479. private _reflection2DCoordsName;
  57480. private _reflectionColorName;
  57481. private _reflectionMatrixName;
  57482. /**
  57483. * Gets or sets the texture associated with the node
  57484. */
  57485. texture: Nullable<BaseTexture>;
  57486. /**
  57487. * Create a new TextureBlock
  57488. * @param name defines the block name
  57489. */
  57490. constructor(name: string);
  57491. /**
  57492. * Gets the current class name
  57493. * @returns the class name
  57494. */
  57495. getClassName(): string;
  57496. /**
  57497. * Gets the world position input component
  57498. */
  57499. get position(): NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the world position input component
  57502. */
  57503. get worldPosition(): NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the world normal input component
  57506. */
  57507. get worldNormal(): NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the world input component
  57510. */
  57511. get world(): NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the camera (or eye) position component
  57514. */
  57515. get cameraPosition(): NodeMaterialConnectionPoint;
  57516. /**
  57517. * Gets the view input component
  57518. */
  57519. get view(): NodeMaterialConnectionPoint;
  57520. /**
  57521. * Gets the rgb output component
  57522. */
  57523. get rgb(): NodeMaterialConnectionPoint;
  57524. /**
  57525. * Gets the r output component
  57526. */
  57527. get r(): NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the g output component
  57530. */
  57531. get g(): NodeMaterialConnectionPoint;
  57532. /**
  57533. * Gets the b output component
  57534. */
  57535. get b(): NodeMaterialConnectionPoint;
  57536. autoConfigure(material: NodeMaterial): void;
  57537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57538. isReady(): boolean;
  57539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57540. private _injectVertexCode;
  57541. private _writeOutput;
  57542. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57543. protected _dumpPropertiesCode(): string;
  57544. serialize(): any;
  57545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57546. }
  57547. }
  57548. declare module BABYLON {
  57549. /**
  57550. * Interface used to configure the node material editor
  57551. */
  57552. export interface INodeMaterialEditorOptions {
  57553. /** Define the URl to load node editor script */
  57554. editorURL?: string;
  57555. }
  57556. /** @hidden */
  57557. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57558. NORMAL: boolean;
  57559. TANGENT: boolean;
  57560. UV1: boolean;
  57561. /** BONES */
  57562. NUM_BONE_INFLUENCERS: number;
  57563. BonesPerMesh: number;
  57564. BONETEXTURE: boolean;
  57565. /** MORPH TARGETS */
  57566. MORPHTARGETS: boolean;
  57567. MORPHTARGETS_NORMAL: boolean;
  57568. MORPHTARGETS_TANGENT: boolean;
  57569. MORPHTARGETS_UV: boolean;
  57570. NUM_MORPH_INFLUENCERS: number;
  57571. /** IMAGE PROCESSING */
  57572. IMAGEPROCESSING: boolean;
  57573. VIGNETTE: boolean;
  57574. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57575. VIGNETTEBLENDMODEOPAQUE: boolean;
  57576. TONEMAPPING: boolean;
  57577. TONEMAPPING_ACES: boolean;
  57578. CONTRAST: boolean;
  57579. EXPOSURE: boolean;
  57580. COLORCURVES: boolean;
  57581. COLORGRADING: boolean;
  57582. COLORGRADING3D: boolean;
  57583. SAMPLER3DGREENDEPTH: boolean;
  57584. SAMPLER3DBGRMAP: boolean;
  57585. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57586. /** MISC. */
  57587. BUMPDIRECTUV: number;
  57588. constructor();
  57589. setValue(name: string, value: boolean): void;
  57590. }
  57591. /**
  57592. * Class used to configure NodeMaterial
  57593. */
  57594. export interface INodeMaterialOptions {
  57595. /**
  57596. * Defines if blocks should emit comments
  57597. */
  57598. emitComments: boolean;
  57599. }
  57600. /**
  57601. * Class used to create a node based material built by assembling shader blocks
  57602. */
  57603. export class NodeMaterial extends PushMaterial {
  57604. private static _BuildIdGenerator;
  57605. private _options;
  57606. private _vertexCompilationState;
  57607. private _fragmentCompilationState;
  57608. private _sharedData;
  57609. private _buildId;
  57610. private _buildWasSuccessful;
  57611. private _cachedWorldViewMatrix;
  57612. private _cachedWorldViewProjectionMatrix;
  57613. private _optimizers;
  57614. private _animationFrame;
  57615. /** Define the Url to load node editor script */
  57616. static EditorURL: string;
  57617. /** Define the Url to load snippets */
  57618. static SnippetUrl: string;
  57619. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57620. static IgnoreTexturesAtLoadTime: boolean;
  57621. private BJSNODEMATERIALEDITOR;
  57622. /** Get the inspector from bundle or global */
  57623. private _getGlobalNodeMaterialEditor;
  57624. /**
  57625. * Snippet ID if the material was created from the snippet server
  57626. */
  57627. snippetId: string;
  57628. /**
  57629. * Gets or sets data used by visual editor
  57630. * @see https://nme.babylonjs.com
  57631. */
  57632. editorData: any;
  57633. /**
  57634. * 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)
  57635. */
  57636. ignoreAlpha: boolean;
  57637. /**
  57638. * Defines the maximum number of lights that can be used in the material
  57639. */
  57640. maxSimultaneousLights: number;
  57641. /**
  57642. * Observable raised when the material is built
  57643. */
  57644. onBuildObservable: Observable<NodeMaterial>;
  57645. /**
  57646. * Gets or sets the root nodes of the material vertex shader
  57647. */
  57648. _vertexOutputNodes: NodeMaterialBlock[];
  57649. /**
  57650. * Gets or sets the root nodes of the material fragment (pixel) shader
  57651. */
  57652. _fragmentOutputNodes: NodeMaterialBlock[];
  57653. /** Gets or sets options to control the node material overall behavior */
  57654. get options(): INodeMaterialOptions;
  57655. set options(options: INodeMaterialOptions);
  57656. /**
  57657. * Default configuration related to image processing available in the standard Material.
  57658. */
  57659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57660. /**
  57661. * Gets the image processing configuration used either in this material.
  57662. */
  57663. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57664. /**
  57665. * Sets the Default image processing configuration used either in the this material.
  57666. *
  57667. * If sets to null, the scene one is in use.
  57668. */
  57669. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57670. /**
  57671. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57672. */
  57673. attachedBlocks: NodeMaterialBlock[];
  57674. /**
  57675. * Create a new node based material
  57676. * @param name defines the material name
  57677. * @param scene defines the hosting scene
  57678. * @param options defines creation option
  57679. */
  57680. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57681. /**
  57682. * Gets the current class name of the material e.g. "NodeMaterial"
  57683. * @returns the class name
  57684. */
  57685. getClassName(): string;
  57686. /**
  57687. * Keep track of the image processing observer to allow dispose and replace.
  57688. */
  57689. private _imageProcessingObserver;
  57690. /**
  57691. * Attaches a new image processing configuration to the Standard Material.
  57692. * @param configuration
  57693. */
  57694. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57695. /**
  57696. * Get a block by its name
  57697. * @param name defines the name of the block to retrieve
  57698. * @returns the required block or null if not found
  57699. */
  57700. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57701. /**
  57702. * Get a block by its name
  57703. * @param predicate defines the predicate used to find the good candidate
  57704. * @returns the required block or null if not found
  57705. */
  57706. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57707. /**
  57708. * Get an input block by its name
  57709. * @param predicate defines the predicate used to find the good candidate
  57710. * @returns the required input block or null if not found
  57711. */
  57712. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57713. /**
  57714. * Gets the list of input blocks attached to this material
  57715. * @returns an array of InputBlocks
  57716. */
  57717. getInputBlocks(): InputBlock[];
  57718. /**
  57719. * Adds a new optimizer to the list of optimizers
  57720. * @param optimizer defines the optimizers to add
  57721. * @returns the current material
  57722. */
  57723. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57724. /**
  57725. * Remove an optimizer from the list of optimizers
  57726. * @param optimizer defines the optimizers to remove
  57727. * @returns the current material
  57728. */
  57729. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57730. /**
  57731. * Add a new block to the list of output nodes
  57732. * @param node defines the node to add
  57733. * @returns the current material
  57734. */
  57735. addOutputNode(node: NodeMaterialBlock): this;
  57736. /**
  57737. * Remove a block from the list of root nodes
  57738. * @param node defines the node to remove
  57739. * @returns the current material
  57740. */
  57741. removeOutputNode(node: NodeMaterialBlock): this;
  57742. private _addVertexOutputNode;
  57743. private _removeVertexOutputNode;
  57744. private _addFragmentOutputNode;
  57745. private _removeFragmentOutputNode;
  57746. /**
  57747. * Specifies if the material will require alpha blending
  57748. * @returns a boolean specifying if alpha blending is needed
  57749. */
  57750. needAlphaBlending(): boolean;
  57751. /**
  57752. * Specifies if this material should be rendered in alpha test mode
  57753. * @returns a boolean specifying if an alpha test is needed.
  57754. */
  57755. needAlphaTesting(): boolean;
  57756. private _initializeBlock;
  57757. private _resetDualBlocks;
  57758. /**
  57759. * Remove a block from the current node material
  57760. * @param block defines the block to remove
  57761. */
  57762. removeBlock(block: NodeMaterialBlock): void;
  57763. /**
  57764. * Build the material and generates the inner effect
  57765. * @param verbose defines if the build should log activity
  57766. */
  57767. build(verbose?: boolean): void;
  57768. /**
  57769. * Runs an otpimization phase to try to improve the shader code
  57770. */
  57771. optimize(): void;
  57772. private _prepareDefinesForAttributes;
  57773. /**
  57774. * Get if the submesh is ready to be used and all its information available.
  57775. * Child classes can use it to update shaders
  57776. * @param mesh defines the mesh to check
  57777. * @param subMesh defines which submesh to check
  57778. * @param useInstances specifies that instances should be used
  57779. * @returns a boolean indicating that the submesh is ready or not
  57780. */
  57781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57782. /**
  57783. * Get a string representing the shaders built by the current node graph
  57784. */
  57785. get compiledShaders(): string;
  57786. /**
  57787. * Binds the world matrix to the material
  57788. * @param world defines the world transformation matrix
  57789. */
  57790. bindOnlyWorldMatrix(world: Matrix): void;
  57791. /**
  57792. * Binds the submesh to this material by preparing the effect and shader to draw
  57793. * @param world defines the world transformation matrix
  57794. * @param mesh defines the mesh containing the submesh
  57795. * @param subMesh defines the submesh to bind the material to
  57796. */
  57797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57798. /**
  57799. * Gets the active textures from the material
  57800. * @returns an array of textures
  57801. */
  57802. getActiveTextures(): BaseTexture[];
  57803. /**
  57804. * Gets the list of texture blocks
  57805. * @returns an array of texture blocks
  57806. */
  57807. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57808. /**
  57809. * Specifies if the material uses a texture
  57810. * @param texture defines the texture to check against the material
  57811. * @returns a boolean specifying if the material uses the texture
  57812. */
  57813. hasTexture(texture: BaseTexture): boolean;
  57814. /**
  57815. * Disposes the material
  57816. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57817. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57818. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57819. */
  57820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57821. /** Creates the node editor window. */
  57822. private _createNodeEditor;
  57823. /**
  57824. * Launch the node material editor
  57825. * @param config Define the configuration of the editor
  57826. * @return a promise fulfilled when the node editor is visible
  57827. */
  57828. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57829. /**
  57830. * Clear the current material
  57831. */
  57832. clear(): void;
  57833. /**
  57834. * Clear the current material and set it to a default state
  57835. */
  57836. setToDefault(): void;
  57837. /**
  57838. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57839. * @param url defines the url to load from
  57840. * @returns a promise that will fullfil when the material is fully loaded
  57841. */
  57842. loadAsync(url: string): Promise<void>;
  57843. private _gatherBlocks;
  57844. /**
  57845. * Generate a string containing the code declaration required to create an equivalent of this material
  57846. * @returns a string
  57847. */
  57848. generateCode(): string;
  57849. /**
  57850. * Serializes this material in a JSON representation
  57851. * @returns the serialized material object
  57852. */
  57853. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57854. private _restoreConnections;
  57855. /**
  57856. * Clear the current graph and load a new one from a serialization object
  57857. * @param source defines the JSON representation of the material
  57858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57859. */
  57860. loadFromSerialization(source: any, rootUrl?: string): void;
  57861. /**
  57862. * Makes a duplicate of the current material.
  57863. * @param name - name to use for the new material.
  57864. */
  57865. clone(name: string): NodeMaterial;
  57866. /**
  57867. * Creates a node material from parsed material data
  57868. * @param source defines the JSON representation of the material
  57869. * @param scene defines the hosting scene
  57870. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57871. * @returns a new node material
  57872. */
  57873. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57874. /**
  57875. * Creates a node material from a snippet saved in a remote file
  57876. * @param name defines the name of the material to create
  57877. * @param url defines the url to load from
  57878. * @param scene defines the hosting scene
  57879. * @returns a promise that will resolve to the new node material
  57880. */
  57881. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57882. /**
  57883. * Creates a node material from a snippet saved by the node material editor
  57884. * @param snippetId defines the snippet to load
  57885. * @param scene defines the hosting scene
  57886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57887. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57888. * @returns a promise that will resolve to the new node material
  57889. */
  57890. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57891. /**
  57892. * Creates a new node material set to default basic configuration
  57893. * @param name defines the name of the material
  57894. * @param scene defines the hosting scene
  57895. * @returns a new NodeMaterial
  57896. */
  57897. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57898. }
  57899. }
  57900. declare module BABYLON {
  57901. /**
  57902. * Block used to read a texture from a sampler
  57903. */
  57904. export class TextureBlock extends NodeMaterialBlock {
  57905. private _defineName;
  57906. private _linearDefineName;
  57907. private _tempTextureRead;
  57908. private _samplerName;
  57909. private _transformedUVName;
  57910. private _textureTransformName;
  57911. private _textureInfoName;
  57912. private _mainUVName;
  57913. private _mainUVDefineName;
  57914. /**
  57915. * Gets or sets the texture associated with the node
  57916. */
  57917. texture: Nullable<Texture>;
  57918. /**
  57919. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57920. */
  57921. convertToGammaSpace: boolean;
  57922. /**
  57923. * Create a new TextureBlock
  57924. * @param name defines the block name
  57925. */
  57926. constructor(name: string);
  57927. /**
  57928. * Gets the current class name
  57929. * @returns the class name
  57930. */
  57931. getClassName(): string;
  57932. /**
  57933. * Gets the uv input component
  57934. */
  57935. get uv(): NodeMaterialConnectionPoint;
  57936. /**
  57937. * Gets the rgba output component
  57938. */
  57939. get rgba(): NodeMaterialConnectionPoint;
  57940. /**
  57941. * Gets the rgb output component
  57942. */
  57943. get rgb(): NodeMaterialConnectionPoint;
  57944. /**
  57945. * Gets the r output component
  57946. */
  57947. get r(): NodeMaterialConnectionPoint;
  57948. /**
  57949. * Gets the g output component
  57950. */
  57951. get g(): NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the b output component
  57954. */
  57955. get b(): NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the a output component
  57958. */
  57959. get a(): NodeMaterialConnectionPoint;
  57960. get target(): NodeMaterialBlockTargets;
  57961. autoConfigure(material: NodeMaterial): void;
  57962. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57964. isReady(): boolean;
  57965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57966. private get _isMixed();
  57967. private _injectVertexCode;
  57968. private _writeTextureRead;
  57969. private _writeOutput;
  57970. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57971. protected _dumpPropertiesCode(): string;
  57972. serialize(): any;
  57973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57974. }
  57975. }
  57976. declare module BABYLON {
  57977. /**
  57978. * Class used to store shared data between 2 NodeMaterialBuildState
  57979. */
  57980. export class NodeMaterialBuildStateSharedData {
  57981. /**
  57982. * Gets the list of emitted varyings
  57983. */
  57984. temps: string[];
  57985. /**
  57986. * Gets the list of emitted varyings
  57987. */
  57988. varyings: string[];
  57989. /**
  57990. * Gets the varying declaration string
  57991. */
  57992. varyingDeclaration: string;
  57993. /**
  57994. * Input blocks
  57995. */
  57996. inputBlocks: InputBlock[];
  57997. /**
  57998. * Input blocks
  57999. */
  58000. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58001. /**
  58002. * Bindable blocks (Blocks that need to set data to the effect)
  58003. */
  58004. bindableBlocks: NodeMaterialBlock[];
  58005. /**
  58006. * List of blocks that can provide a compilation fallback
  58007. */
  58008. blocksWithFallbacks: NodeMaterialBlock[];
  58009. /**
  58010. * List of blocks that can provide a define update
  58011. */
  58012. blocksWithDefines: NodeMaterialBlock[];
  58013. /**
  58014. * List of blocks that can provide a repeatable content
  58015. */
  58016. repeatableContentBlocks: NodeMaterialBlock[];
  58017. /**
  58018. * List of blocks that can provide a dynamic list of uniforms
  58019. */
  58020. dynamicUniformBlocks: NodeMaterialBlock[];
  58021. /**
  58022. * List of blocks that can block the isReady function for the material
  58023. */
  58024. blockingBlocks: NodeMaterialBlock[];
  58025. /**
  58026. * Gets the list of animated inputs
  58027. */
  58028. animatedInputs: InputBlock[];
  58029. /**
  58030. * Build Id used to avoid multiple recompilations
  58031. */
  58032. buildId: number;
  58033. /** List of emitted variables */
  58034. variableNames: {
  58035. [key: string]: number;
  58036. };
  58037. /** List of emitted defines */
  58038. defineNames: {
  58039. [key: string]: number;
  58040. };
  58041. /** Should emit comments? */
  58042. emitComments: boolean;
  58043. /** Emit build activity */
  58044. verbose: boolean;
  58045. /** Gets or sets the hosting scene */
  58046. scene: Scene;
  58047. /**
  58048. * Gets the compilation hints emitted at compilation time
  58049. */
  58050. hints: {
  58051. needWorldViewMatrix: boolean;
  58052. needWorldViewProjectionMatrix: boolean;
  58053. needAlphaBlending: boolean;
  58054. needAlphaTesting: boolean;
  58055. };
  58056. /**
  58057. * List of compilation checks
  58058. */
  58059. checks: {
  58060. emitVertex: boolean;
  58061. emitFragment: boolean;
  58062. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58063. };
  58064. /** Creates a new shared data */
  58065. constructor();
  58066. /**
  58067. * Emits console errors and exceptions if there is a failing check
  58068. */
  58069. emitErrors(): void;
  58070. }
  58071. }
  58072. declare module BABYLON {
  58073. /**
  58074. * Class used to store node based material build state
  58075. */
  58076. export class NodeMaterialBuildState {
  58077. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58078. supportUniformBuffers: boolean;
  58079. /**
  58080. * Gets the list of emitted attributes
  58081. */
  58082. attributes: string[];
  58083. /**
  58084. * Gets the list of emitted uniforms
  58085. */
  58086. uniforms: string[];
  58087. /**
  58088. * Gets the list of emitted constants
  58089. */
  58090. constants: string[];
  58091. /**
  58092. * Gets the list of emitted samplers
  58093. */
  58094. samplers: string[];
  58095. /**
  58096. * Gets the list of emitted functions
  58097. */
  58098. functions: {
  58099. [key: string]: string;
  58100. };
  58101. /**
  58102. * Gets the list of emitted extensions
  58103. */
  58104. extensions: {
  58105. [key: string]: string;
  58106. };
  58107. /**
  58108. * Gets the target of the compilation state
  58109. */
  58110. target: NodeMaterialBlockTargets;
  58111. /**
  58112. * Gets the list of emitted counters
  58113. */
  58114. counters: {
  58115. [key: string]: number;
  58116. };
  58117. /**
  58118. * Shared data between multiple NodeMaterialBuildState instances
  58119. */
  58120. sharedData: NodeMaterialBuildStateSharedData;
  58121. /** @hidden */
  58122. _vertexState: NodeMaterialBuildState;
  58123. /** @hidden */
  58124. _attributeDeclaration: string;
  58125. /** @hidden */
  58126. _uniformDeclaration: string;
  58127. /** @hidden */
  58128. _constantDeclaration: string;
  58129. /** @hidden */
  58130. _samplerDeclaration: string;
  58131. /** @hidden */
  58132. _varyingTransfer: string;
  58133. private _repeatableContentAnchorIndex;
  58134. /** @hidden */
  58135. _builtCompilationString: string;
  58136. /**
  58137. * Gets the emitted compilation strings
  58138. */
  58139. compilationString: string;
  58140. /**
  58141. * Finalize the compilation strings
  58142. * @param state defines the current compilation state
  58143. */
  58144. finalize(state: NodeMaterialBuildState): void;
  58145. /** @hidden */
  58146. get _repeatableContentAnchor(): string;
  58147. /** @hidden */
  58148. _getFreeVariableName(prefix: string): string;
  58149. /** @hidden */
  58150. _getFreeDefineName(prefix: string): string;
  58151. /** @hidden */
  58152. _excludeVariableName(name: string): void;
  58153. /** @hidden */
  58154. _emit2DSampler(name: string): void;
  58155. /** @hidden */
  58156. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58157. /** @hidden */
  58158. _emitExtension(name: string, extension: string): void;
  58159. /** @hidden */
  58160. _emitFunction(name: string, code: string, comments: string): void;
  58161. /** @hidden */
  58162. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58163. replaceStrings?: {
  58164. search: RegExp;
  58165. replace: string;
  58166. }[];
  58167. repeatKey?: string;
  58168. }): string;
  58169. /** @hidden */
  58170. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58171. repeatKey?: string;
  58172. removeAttributes?: boolean;
  58173. removeUniforms?: boolean;
  58174. removeVaryings?: boolean;
  58175. removeIfDef?: boolean;
  58176. replaceStrings?: {
  58177. search: RegExp;
  58178. replace: string;
  58179. }[];
  58180. }, storeKey?: string): void;
  58181. /** @hidden */
  58182. _registerTempVariable(name: string): boolean;
  58183. /** @hidden */
  58184. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58185. /** @hidden */
  58186. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58187. /** @hidden */
  58188. _emitFloat(value: number): string;
  58189. }
  58190. }
  58191. declare module BABYLON {
  58192. /**
  58193. * Defines a block that can be used inside a node based material
  58194. */
  58195. export class NodeMaterialBlock {
  58196. private _buildId;
  58197. private _buildTarget;
  58198. private _target;
  58199. private _isFinalMerger;
  58200. private _isInput;
  58201. protected _isUnique: boolean;
  58202. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58203. inputsAreExclusive: boolean;
  58204. /** @hidden */
  58205. _codeVariableName: string;
  58206. /** @hidden */
  58207. _inputs: NodeMaterialConnectionPoint[];
  58208. /** @hidden */
  58209. _outputs: NodeMaterialConnectionPoint[];
  58210. /** @hidden */
  58211. _preparationId: number;
  58212. /**
  58213. * Gets or sets the name of the block
  58214. */
  58215. name: string;
  58216. /**
  58217. * Gets or sets the unique id of the node
  58218. */
  58219. uniqueId: number;
  58220. /**
  58221. * Gets or sets the comments associated with this block
  58222. */
  58223. comments: string;
  58224. /**
  58225. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58226. */
  58227. get isUnique(): boolean;
  58228. /**
  58229. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58230. */
  58231. get isFinalMerger(): boolean;
  58232. /**
  58233. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58234. */
  58235. get isInput(): boolean;
  58236. /**
  58237. * Gets or sets the build Id
  58238. */
  58239. get buildId(): number;
  58240. set buildId(value: number);
  58241. /**
  58242. * Gets or sets the target of the block
  58243. */
  58244. get target(): NodeMaterialBlockTargets;
  58245. set target(value: NodeMaterialBlockTargets);
  58246. /**
  58247. * Gets the list of input points
  58248. */
  58249. get inputs(): NodeMaterialConnectionPoint[];
  58250. /** Gets the list of output points */
  58251. get outputs(): NodeMaterialConnectionPoint[];
  58252. /**
  58253. * Find an input by its name
  58254. * @param name defines the name of the input to look for
  58255. * @returns the input or null if not found
  58256. */
  58257. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58258. /**
  58259. * Find an output by its name
  58260. * @param name defines the name of the outputto look for
  58261. * @returns the output or null if not found
  58262. */
  58263. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58264. /**
  58265. * Creates a new NodeMaterialBlock
  58266. * @param name defines the block name
  58267. * @param target defines the target of that block (Vertex by default)
  58268. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58269. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58270. */
  58271. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58272. /**
  58273. * Initialize the block and prepare the context for build
  58274. * @param state defines the state that will be used for the build
  58275. */
  58276. initialize(state: NodeMaterialBuildState): void;
  58277. /**
  58278. * Bind data to effect. Will only be called for blocks with isBindable === true
  58279. * @param effect defines the effect to bind data to
  58280. * @param nodeMaterial defines the hosting NodeMaterial
  58281. * @param mesh defines the mesh that will be rendered
  58282. */
  58283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58284. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58285. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58286. protected _writeFloat(value: number): string;
  58287. /**
  58288. * Gets the current class name e.g. "NodeMaterialBlock"
  58289. * @returns the class name
  58290. */
  58291. getClassName(): string;
  58292. /**
  58293. * Register a new input. Must be called inside a block constructor
  58294. * @param name defines the connection point name
  58295. * @param type defines the connection point type
  58296. * @param isOptional defines a boolean indicating that this input can be omitted
  58297. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58298. * @returns the current block
  58299. */
  58300. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58301. /**
  58302. * Register a new output. Must be called inside a block constructor
  58303. * @param name defines the connection point name
  58304. * @param type defines the connection point type
  58305. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58306. * @returns the current block
  58307. */
  58308. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58309. /**
  58310. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58311. * @param forOutput defines an optional connection point to check compatibility with
  58312. * @returns the first available input or null
  58313. */
  58314. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58315. /**
  58316. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58317. * @param forBlock defines an optional block to check compatibility with
  58318. * @returns the first available input or null
  58319. */
  58320. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58321. /**
  58322. * Gets the sibling of the given output
  58323. * @param current defines the current output
  58324. * @returns the next output in the list or null
  58325. */
  58326. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58327. /**
  58328. * Connect current block with another block
  58329. * @param other defines the block to connect with
  58330. * @param options define the various options to help pick the right connections
  58331. * @returns the current block
  58332. */
  58333. connectTo(other: NodeMaterialBlock, options?: {
  58334. input?: string;
  58335. output?: string;
  58336. outputSwizzle?: string;
  58337. }): this | undefined;
  58338. protected _buildBlock(state: NodeMaterialBuildState): void;
  58339. /**
  58340. * Add uniforms, samplers and uniform buffers at compilation time
  58341. * @param state defines the state to update
  58342. * @param nodeMaterial defines the node material requesting the update
  58343. * @param defines defines the material defines to update
  58344. * @param uniformBuffers defines the list of uniform buffer names
  58345. */
  58346. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58347. /**
  58348. * Add potential fallbacks if shader compilation fails
  58349. * @param mesh defines the mesh to be rendered
  58350. * @param fallbacks defines the current prioritized list of fallbacks
  58351. */
  58352. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58353. /**
  58354. * Initialize defines for shader compilation
  58355. * @param mesh defines the mesh to be rendered
  58356. * @param nodeMaterial defines the node material requesting the update
  58357. * @param defines defines the material defines to update
  58358. * @param useInstances specifies that instances should be used
  58359. */
  58360. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58361. /**
  58362. * Update defines for shader compilation
  58363. * @param mesh defines the mesh to be rendered
  58364. * @param nodeMaterial defines the node material requesting the update
  58365. * @param defines defines the material defines to update
  58366. * @param useInstances specifies that instances should be used
  58367. */
  58368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58369. /**
  58370. * Lets the block try to connect some inputs automatically
  58371. * @param material defines the hosting NodeMaterial
  58372. */
  58373. autoConfigure(material: NodeMaterial): void;
  58374. /**
  58375. * Function called when a block is declared as repeatable content generator
  58376. * @param vertexShaderState defines the current compilation state for the vertex shader
  58377. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58378. * @param mesh defines the mesh to be rendered
  58379. * @param defines defines the material defines to update
  58380. */
  58381. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58382. /**
  58383. * Checks if the block is ready
  58384. * @param mesh defines the mesh to be rendered
  58385. * @param nodeMaterial defines the node material requesting the update
  58386. * @param defines defines the material defines to update
  58387. * @param useInstances specifies that instances should be used
  58388. * @returns true if the block is ready
  58389. */
  58390. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58391. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58392. private _processBuild;
  58393. /**
  58394. * Compile the current node and generate the shader code
  58395. * @param state defines the current compilation state (uniforms, samplers, current string)
  58396. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58397. * @returns true if already built
  58398. */
  58399. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58400. protected _inputRename(name: string): string;
  58401. protected _outputRename(name: string): string;
  58402. protected _dumpPropertiesCode(): string;
  58403. /** @hidden */
  58404. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58405. /** @hidden */
  58406. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58407. /**
  58408. * Clone the current block to a new identical block
  58409. * @param scene defines the hosting scene
  58410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58411. * @returns a copy of the current block
  58412. */
  58413. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58414. /**
  58415. * Serializes this block in a JSON representation
  58416. * @returns the serialized block object
  58417. */
  58418. serialize(): any;
  58419. /** @hidden */
  58420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58421. /**
  58422. * Release resources
  58423. */
  58424. dispose(): void;
  58425. }
  58426. }
  58427. declare module BABYLON {
  58428. /**
  58429. * Enum defining the type of animations supported by InputBlock
  58430. */
  58431. export enum AnimatedInputBlockTypes {
  58432. /** No animation */
  58433. None = 0,
  58434. /** Time based animation. Will only work for floats */
  58435. Time = 1
  58436. }
  58437. }
  58438. declare module BABYLON {
  58439. /**
  58440. * Block used to expose an input value
  58441. */
  58442. export class InputBlock extends NodeMaterialBlock {
  58443. private _mode;
  58444. private _associatedVariableName;
  58445. private _storedValue;
  58446. private _valueCallback;
  58447. private _type;
  58448. private _animationType;
  58449. /** Gets or set a value used to limit the range of float values */
  58450. min: number;
  58451. /** Gets or set a value used to limit the range of float values */
  58452. max: number;
  58453. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58454. isBoolean: boolean;
  58455. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58456. matrixMode: number;
  58457. /** @hidden */
  58458. _systemValue: Nullable<NodeMaterialSystemValues>;
  58459. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58460. visibleInInspector: boolean;
  58461. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58462. isConstant: boolean;
  58463. /** Gets or sets the group to use to display this block in the Inspector */
  58464. groupInInspector: string;
  58465. /** Gets an observable raised when the value is changed */
  58466. onValueChangedObservable: Observable<InputBlock>;
  58467. /**
  58468. * Gets or sets the connection point type (default is float)
  58469. */
  58470. get type(): NodeMaterialBlockConnectionPointTypes;
  58471. /**
  58472. * Creates a new InputBlock
  58473. * @param name defines the block name
  58474. * @param target defines the target of that block (Vertex by default)
  58475. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58476. */
  58477. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58478. /**
  58479. * Gets the output component
  58480. */
  58481. get output(): NodeMaterialConnectionPoint;
  58482. /**
  58483. * Set the source of this connection point to a vertex attribute
  58484. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58485. * @returns the current connection point
  58486. */
  58487. setAsAttribute(attributeName?: string): InputBlock;
  58488. /**
  58489. * Set the source of this connection point to a system value
  58490. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58491. * @returns the current connection point
  58492. */
  58493. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58494. /**
  58495. * Gets or sets the value of that point.
  58496. * Please note that this value will be ignored if valueCallback is defined
  58497. */
  58498. get value(): any;
  58499. set value(value: any);
  58500. /**
  58501. * Gets or sets a callback used to get the value of that point.
  58502. * Please note that setting this value will force the connection point to ignore the value property
  58503. */
  58504. get valueCallback(): () => any;
  58505. set valueCallback(value: () => any);
  58506. /**
  58507. * Gets or sets the associated variable name in the shader
  58508. */
  58509. get associatedVariableName(): string;
  58510. set associatedVariableName(value: string);
  58511. /** Gets or sets the type of animation applied to the input */
  58512. get animationType(): AnimatedInputBlockTypes;
  58513. set animationType(value: AnimatedInputBlockTypes);
  58514. /**
  58515. * Gets a boolean indicating that this connection point not defined yet
  58516. */
  58517. get isUndefined(): boolean;
  58518. /**
  58519. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58520. * In this case the connection point name must be the name of the uniform to use.
  58521. * Can only be set on inputs
  58522. */
  58523. get isUniform(): boolean;
  58524. set isUniform(value: boolean);
  58525. /**
  58526. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58527. * In this case the connection point name must be the name of the attribute to use
  58528. * Can only be set on inputs
  58529. */
  58530. get isAttribute(): boolean;
  58531. set isAttribute(value: boolean);
  58532. /**
  58533. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58534. * Can only be set on exit points
  58535. */
  58536. get isVarying(): boolean;
  58537. set isVarying(value: boolean);
  58538. /**
  58539. * Gets a boolean indicating that the current connection point is a system value
  58540. */
  58541. get isSystemValue(): boolean;
  58542. /**
  58543. * Gets or sets the current well known value or null if not defined as a system value
  58544. */
  58545. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58546. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58547. /**
  58548. * Gets the current class name
  58549. * @returns the class name
  58550. */
  58551. getClassName(): string;
  58552. /**
  58553. * Animate the input if animationType !== None
  58554. * @param scene defines the rendering scene
  58555. */
  58556. animate(scene: Scene): void;
  58557. private _emitDefine;
  58558. initialize(state: NodeMaterialBuildState): void;
  58559. /**
  58560. * Set the input block to its default value (based on its type)
  58561. */
  58562. setDefaultValue(): void;
  58563. private _emitConstant;
  58564. private _emit;
  58565. /** @hidden */
  58566. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58567. /** @hidden */
  58568. _transmit(effect: Effect, scene: Scene): void;
  58569. protected _buildBlock(state: NodeMaterialBuildState): void;
  58570. protected _dumpPropertiesCode(): string;
  58571. dispose(): void;
  58572. serialize(): any;
  58573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58574. }
  58575. }
  58576. declare module BABYLON {
  58577. /**
  58578. * Enum used to define the compatibility state between two connection points
  58579. */
  58580. export enum NodeMaterialConnectionPointCompatibilityStates {
  58581. /** Points are compatibles */
  58582. Compatible = 0,
  58583. /** Points are incompatible because of their types */
  58584. TypeIncompatible = 1,
  58585. /** Points are incompatible because of their targets (vertex vs fragment) */
  58586. TargetIncompatible = 2
  58587. }
  58588. /**
  58589. * Defines the direction of a connection point
  58590. */
  58591. export enum NodeMaterialConnectionPointDirection {
  58592. /** Input */
  58593. Input = 0,
  58594. /** Output */
  58595. Output = 1
  58596. }
  58597. /**
  58598. * Defines a connection point for a block
  58599. */
  58600. export class NodeMaterialConnectionPoint {
  58601. /** @hidden */
  58602. _ownerBlock: NodeMaterialBlock;
  58603. /** @hidden */
  58604. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58605. private _endpoints;
  58606. private _associatedVariableName;
  58607. private _direction;
  58608. /** @hidden */
  58609. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58610. /** @hidden */
  58611. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58612. private _type;
  58613. /** @hidden */
  58614. _enforceAssociatedVariableName: boolean;
  58615. /** Gets the direction of the point */
  58616. get direction(): NodeMaterialConnectionPointDirection;
  58617. /**
  58618. * Gets or sets the additional types supported by this connection point
  58619. */
  58620. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58621. /**
  58622. * Gets or sets the additional types excluded by this connection point
  58623. */
  58624. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58625. /**
  58626. * Observable triggered when this point is connected
  58627. */
  58628. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58629. /**
  58630. * Gets or sets the associated variable name in the shader
  58631. */
  58632. get associatedVariableName(): string;
  58633. set associatedVariableName(value: string);
  58634. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58635. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58636. /**
  58637. * Gets or sets the connection point type (default is float)
  58638. */
  58639. get type(): NodeMaterialBlockConnectionPointTypes;
  58640. set type(value: NodeMaterialBlockConnectionPointTypes);
  58641. /**
  58642. * Gets or sets the connection point name
  58643. */
  58644. name: string;
  58645. /**
  58646. * Gets or sets a boolean indicating that this connection point can be omitted
  58647. */
  58648. isOptional: boolean;
  58649. /**
  58650. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58651. */
  58652. define: string;
  58653. /** @hidden */
  58654. _prioritizeVertex: boolean;
  58655. private _target;
  58656. /** Gets or sets the target of that connection point */
  58657. get target(): NodeMaterialBlockTargets;
  58658. set target(value: NodeMaterialBlockTargets);
  58659. /**
  58660. * Gets a boolean indicating that the current point is connected
  58661. */
  58662. get isConnected(): boolean;
  58663. /**
  58664. * Gets a boolean indicating that the current point is connected to an input block
  58665. */
  58666. get isConnectedToInputBlock(): boolean;
  58667. /**
  58668. * Gets a the connected input block (if any)
  58669. */
  58670. get connectInputBlock(): Nullable<InputBlock>;
  58671. /** Get the other side of the connection (if any) */
  58672. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58673. /** Get the block that owns this connection point */
  58674. get ownerBlock(): NodeMaterialBlock;
  58675. /** Get the block connected on the other side of this connection (if any) */
  58676. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58677. /** Get the block connected on the endpoints of this connection (if any) */
  58678. get connectedBlocks(): Array<NodeMaterialBlock>;
  58679. /** Gets the list of connected endpoints */
  58680. get endpoints(): NodeMaterialConnectionPoint[];
  58681. /** Gets a boolean indicating if that output point is connected to at least one input */
  58682. get hasEndpoints(): boolean;
  58683. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58684. get isConnectedInVertexShader(): boolean;
  58685. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58686. get isConnectedInFragmentShader(): boolean;
  58687. /**
  58688. * Creates a new connection point
  58689. * @param name defines the connection point name
  58690. * @param ownerBlock defines the block hosting this connection point
  58691. * @param direction defines the direction of the connection point
  58692. */
  58693. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58694. /**
  58695. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58696. * @returns the class name
  58697. */
  58698. getClassName(): string;
  58699. /**
  58700. * Gets a boolean indicating if the current point can be connected to another point
  58701. * @param connectionPoint defines the other connection point
  58702. * @returns a boolean
  58703. */
  58704. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58705. /**
  58706. * Gets a number indicating if the current point can be connected to another point
  58707. * @param connectionPoint defines the other connection point
  58708. * @returns a number defining the compatibility state
  58709. */
  58710. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58711. /**
  58712. * Connect this point to another connection point
  58713. * @param connectionPoint defines the other connection point
  58714. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58715. * @returns the current connection point
  58716. */
  58717. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58718. /**
  58719. * Disconnect this point from one of his endpoint
  58720. * @param endpoint defines the other connection point
  58721. * @returns the current connection point
  58722. */
  58723. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58724. /**
  58725. * Serializes this point in a JSON representation
  58726. * @returns the serialized point object
  58727. */
  58728. serialize(): any;
  58729. /**
  58730. * Release resources
  58731. */
  58732. dispose(): void;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * Block used to add support for vertex skinning (bones)
  58738. */
  58739. export class BonesBlock extends NodeMaterialBlock {
  58740. /**
  58741. * Creates a new BonesBlock
  58742. * @param name defines the block name
  58743. */
  58744. constructor(name: string);
  58745. /**
  58746. * Initialize the block and prepare the context for build
  58747. * @param state defines the state that will be used for the build
  58748. */
  58749. initialize(state: NodeMaterialBuildState): void;
  58750. /**
  58751. * Gets the current class name
  58752. * @returns the class name
  58753. */
  58754. getClassName(): string;
  58755. /**
  58756. * Gets the matrix indices input component
  58757. */
  58758. get matricesIndices(): NodeMaterialConnectionPoint;
  58759. /**
  58760. * Gets the matrix weights input component
  58761. */
  58762. get matricesWeights(): NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the extra matrix indices input component
  58765. */
  58766. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the extra matrix weights input component
  58769. */
  58770. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58771. /**
  58772. * Gets the world input component
  58773. */
  58774. get world(): NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the output component
  58777. */
  58778. get output(): NodeMaterialConnectionPoint;
  58779. autoConfigure(material: NodeMaterial): void;
  58780. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58781. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58783. protected _buildBlock(state: NodeMaterialBuildState): this;
  58784. }
  58785. }
  58786. declare module BABYLON {
  58787. /**
  58788. * Block used to add support for instances
  58789. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58790. */
  58791. export class InstancesBlock extends NodeMaterialBlock {
  58792. /**
  58793. * Creates a new InstancesBlock
  58794. * @param name defines the block name
  58795. */
  58796. constructor(name: string);
  58797. /**
  58798. * Gets the current class name
  58799. * @returns the class name
  58800. */
  58801. getClassName(): string;
  58802. /**
  58803. * Gets the first world row input component
  58804. */
  58805. get world0(): NodeMaterialConnectionPoint;
  58806. /**
  58807. * Gets the second world row input component
  58808. */
  58809. get world1(): NodeMaterialConnectionPoint;
  58810. /**
  58811. * Gets the third world row input component
  58812. */
  58813. get world2(): NodeMaterialConnectionPoint;
  58814. /**
  58815. * Gets the forth world row input component
  58816. */
  58817. get world3(): NodeMaterialConnectionPoint;
  58818. /**
  58819. * Gets the world input component
  58820. */
  58821. get world(): NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the output component
  58824. */
  58825. get output(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the isntanceID component
  58828. */
  58829. get instanceID(): NodeMaterialConnectionPoint;
  58830. autoConfigure(material: NodeMaterial): void;
  58831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58832. protected _buildBlock(state: NodeMaterialBuildState): this;
  58833. }
  58834. }
  58835. declare module BABYLON {
  58836. /**
  58837. * Block used to add morph targets support to vertex shader
  58838. */
  58839. export class MorphTargetsBlock extends NodeMaterialBlock {
  58840. private _repeatableContentAnchor;
  58841. /**
  58842. * Create a new MorphTargetsBlock
  58843. * @param name defines the block name
  58844. */
  58845. constructor(name: string);
  58846. /**
  58847. * Gets the current class name
  58848. * @returns the class name
  58849. */
  58850. getClassName(): string;
  58851. /**
  58852. * Gets the position input component
  58853. */
  58854. get position(): NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the normal input component
  58857. */
  58858. get normal(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the tangent input component
  58861. */
  58862. get tangent(): NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the tangent input component
  58865. */
  58866. get uv(): NodeMaterialConnectionPoint;
  58867. /**
  58868. * Gets the position output component
  58869. */
  58870. get positionOutput(): NodeMaterialConnectionPoint;
  58871. /**
  58872. * Gets the normal output component
  58873. */
  58874. get normalOutput(): NodeMaterialConnectionPoint;
  58875. /**
  58876. * Gets the tangent output component
  58877. */
  58878. get tangentOutput(): NodeMaterialConnectionPoint;
  58879. /**
  58880. * Gets the tangent output component
  58881. */
  58882. get uvOutput(): NodeMaterialConnectionPoint;
  58883. initialize(state: NodeMaterialBuildState): void;
  58884. autoConfigure(material: NodeMaterial): void;
  58885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58887. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58888. protected _buildBlock(state: NodeMaterialBuildState): this;
  58889. }
  58890. }
  58891. declare module BABYLON {
  58892. /**
  58893. * Block used to get data information from a light
  58894. */
  58895. export class LightInformationBlock extends NodeMaterialBlock {
  58896. private _lightDataUniformName;
  58897. private _lightColorUniformName;
  58898. private _lightTypeDefineName;
  58899. /**
  58900. * Gets or sets the light associated with this block
  58901. */
  58902. light: Nullable<Light>;
  58903. /**
  58904. * Creates a new LightInformationBlock
  58905. * @param name defines the block name
  58906. */
  58907. constructor(name: string);
  58908. /**
  58909. * Gets the current class name
  58910. * @returns the class name
  58911. */
  58912. getClassName(): string;
  58913. /**
  58914. * Gets the world position input component
  58915. */
  58916. get worldPosition(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the direction output component
  58919. */
  58920. get direction(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the direction output component
  58923. */
  58924. get color(): NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the direction output component
  58927. */
  58928. get intensity(): NodeMaterialConnectionPoint;
  58929. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58931. protected _buildBlock(state: NodeMaterialBuildState): this;
  58932. serialize(): any;
  58933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Block used to add image processing support to fragment shader
  58939. */
  58940. export class ImageProcessingBlock extends NodeMaterialBlock {
  58941. /**
  58942. * Create a new ImageProcessingBlock
  58943. * @param name defines the block name
  58944. */
  58945. constructor(name: string);
  58946. /**
  58947. * Gets the current class name
  58948. * @returns the class name
  58949. */
  58950. getClassName(): string;
  58951. /**
  58952. * Gets the color input component
  58953. */
  58954. get color(): NodeMaterialConnectionPoint;
  58955. /**
  58956. * Gets the output component
  58957. */
  58958. get output(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Initialize the block and prepare the context for build
  58961. * @param state defines the state that will be used for the build
  58962. */
  58963. initialize(state: NodeMaterialBuildState): void;
  58964. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58967. protected _buildBlock(state: NodeMaterialBuildState): this;
  58968. }
  58969. }
  58970. declare module BABYLON {
  58971. /**
  58972. * Block used to pertub normals based on a normal map
  58973. */
  58974. export class PerturbNormalBlock extends NodeMaterialBlock {
  58975. private _tangentSpaceParameterName;
  58976. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58977. invertX: boolean;
  58978. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58979. invertY: boolean;
  58980. /**
  58981. * Create a new PerturbNormalBlock
  58982. * @param name defines the block name
  58983. */
  58984. constructor(name: string);
  58985. /**
  58986. * Gets the current class name
  58987. * @returns the class name
  58988. */
  58989. getClassName(): string;
  58990. /**
  58991. * Gets the world position input component
  58992. */
  58993. get worldPosition(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the world normal input component
  58996. */
  58997. get worldNormal(): NodeMaterialConnectionPoint;
  58998. /**
  58999. * Gets the world tangent input component
  59000. */
  59001. get worldTangent(): NodeMaterialConnectionPoint;
  59002. /**
  59003. * Gets the uv input component
  59004. */
  59005. get uv(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the normal map color input component
  59008. */
  59009. get normalMapColor(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the strength input component
  59012. */
  59013. get strength(): NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the output component
  59016. */
  59017. get output(): NodeMaterialConnectionPoint;
  59018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59020. autoConfigure(material: NodeMaterial): void;
  59021. protected _buildBlock(state: NodeMaterialBuildState): this;
  59022. protected _dumpPropertiesCode(): string;
  59023. serialize(): any;
  59024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59025. }
  59026. }
  59027. declare module BABYLON {
  59028. /**
  59029. * Block used to discard a pixel if a value is smaller than a cutoff
  59030. */
  59031. export class DiscardBlock extends NodeMaterialBlock {
  59032. /**
  59033. * Create a new DiscardBlock
  59034. * @param name defines the block name
  59035. */
  59036. constructor(name: string);
  59037. /**
  59038. * Gets the current class name
  59039. * @returns the class name
  59040. */
  59041. getClassName(): string;
  59042. /**
  59043. * Gets the color input component
  59044. */
  59045. get value(): NodeMaterialConnectionPoint;
  59046. /**
  59047. * Gets the cutoff input component
  59048. */
  59049. get cutoff(): NodeMaterialConnectionPoint;
  59050. protected _buildBlock(state: NodeMaterialBuildState): this;
  59051. }
  59052. }
  59053. declare module BABYLON {
  59054. /**
  59055. * Block used to test if the fragment shader is front facing
  59056. */
  59057. export class FrontFacingBlock extends NodeMaterialBlock {
  59058. /**
  59059. * Creates a new FrontFacingBlock
  59060. * @param name defines the block name
  59061. */
  59062. constructor(name: string);
  59063. /**
  59064. * Gets the current class name
  59065. * @returns the class name
  59066. */
  59067. getClassName(): string;
  59068. /**
  59069. * Gets the output component
  59070. */
  59071. get output(): NodeMaterialConnectionPoint;
  59072. protected _buildBlock(state: NodeMaterialBuildState): this;
  59073. }
  59074. }
  59075. declare module BABYLON {
  59076. /**
  59077. * Block used to get the derivative value on x and y of a given input
  59078. */
  59079. export class DerivativeBlock extends NodeMaterialBlock {
  59080. /**
  59081. * Create a new DerivativeBlock
  59082. * @param name defines the block name
  59083. */
  59084. constructor(name: string);
  59085. /**
  59086. * Gets the current class name
  59087. * @returns the class name
  59088. */
  59089. getClassName(): string;
  59090. /**
  59091. * Gets the input component
  59092. */
  59093. get input(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the derivative output on x
  59096. */
  59097. get dx(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the derivative output on y
  59100. */
  59101. get dy(): NodeMaterialConnectionPoint;
  59102. protected _buildBlock(state: NodeMaterialBuildState): this;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Block used to add support for scene fog
  59108. */
  59109. export class FogBlock extends NodeMaterialBlock {
  59110. private _fogDistanceName;
  59111. private _fogParameters;
  59112. /**
  59113. * Create a new FogBlock
  59114. * @param name defines the block name
  59115. */
  59116. constructor(name: string);
  59117. /**
  59118. * Gets the current class name
  59119. * @returns the class name
  59120. */
  59121. getClassName(): string;
  59122. /**
  59123. * Gets the world position input component
  59124. */
  59125. get worldPosition(): NodeMaterialConnectionPoint;
  59126. /**
  59127. * Gets the view input component
  59128. */
  59129. get view(): NodeMaterialConnectionPoint;
  59130. /**
  59131. * Gets the color input component
  59132. */
  59133. get input(): NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the fog color input component
  59136. */
  59137. get fogColor(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the output component
  59140. */
  59141. get output(): NodeMaterialConnectionPoint;
  59142. autoConfigure(material: NodeMaterial): void;
  59143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59145. protected _buildBlock(state: NodeMaterialBuildState): this;
  59146. }
  59147. }
  59148. declare module BABYLON {
  59149. /**
  59150. * Block used to add light in the fragment shader
  59151. */
  59152. export class LightBlock extends NodeMaterialBlock {
  59153. private _lightId;
  59154. /**
  59155. * Gets or sets the light associated with this block
  59156. */
  59157. light: Nullable<Light>;
  59158. /**
  59159. * Create a new LightBlock
  59160. * @param name defines the block name
  59161. */
  59162. constructor(name: string);
  59163. /**
  59164. * Gets the current class name
  59165. * @returns the class name
  59166. */
  59167. getClassName(): string;
  59168. /**
  59169. * Gets the world position input component
  59170. */
  59171. get worldPosition(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the world normal input component
  59174. */
  59175. get worldNormal(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the camera (or eye) position component
  59178. */
  59179. get cameraPosition(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the glossiness component
  59182. */
  59183. get glossiness(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the glossinness power component
  59186. */
  59187. get glossPower(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the diffuse color component
  59190. */
  59191. get diffuseColor(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the specular color component
  59194. */
  59195. get specularColor(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the diffuse output component
  59198. */
  59199. get diffuseOutput(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the specular output component
  59202. */
  59203. get specularOutput(): NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the shadow output component
  59206. */
  59207. get shadow(): NodeMaterialConnectionPoint;
  59208. autoConfigure(material: NodeMaterial): void;
  59209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59210. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59212. private _injectVertexCode;
  59213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59214. serialize(): any;
  59215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59216. }
  59217. }
  59218. declare module BABYLON {
  59219. /**
  59220. * Block used to multiply 2 values
  59221. */
  59222. export class MultiplyBlock extends NodeMaterialBlock {
  59223. /**
  59224. * Creates a new MultiplyBlock
  59225. * @param name defines the block name
  59226. */
  59227. constructor(name: string);
  59228. /**
  59229. * Gets the current class name
  59230. * @returns the class name
  59231. */
  59232. getClassName(): string;
  59233. /**
  59234. * Gets the left operand input component
  59235. */
  59236. get left(): NodeMaterialConnectionPoint;
  59237. /**
  59238. * Gets the right operand input component
  59239. */
  59240. get right(): NodeMaterialConnectionPoint;
  59241. /**
  59242. * Gets the output component
  59243. */
  59244. get output(): NodeMaterialConnectionPoint;
  59245. protected _buildBlock(state: NodeMaterialBuildState): this;
  59246. }
  59247. }
  59248. declare module BABYLON {
  59249. /**
  59250. * Block used to add 2 vectors
  59251. */
  59252. export class AddBlock extends NodeMaterialBlock {
  59253. /**
  59254. * Creates a new AddBlock
  59255. * @param name defines the block name
  59256. */
  59257. constructor(name: string);
  59258. /**
  59259. * Gets the current class name
  59260. * @returns the class name
  59261. */
  59262. getClassName(): string;
  59263. /**
  59264. * Gets the left operand input component
  59265. */
  59266. get left(): NodeMaterialConnectionPoint;
  59267. /**
  59268. * Gets the right operand input component
  59269. */
  59270. get right(): NodeMaterialConnectionPoint;
  59271. /**
  59272. * Gets the output component
  59273. */
  59274. get output(): NodeMaterialConnectionPoint;
  59275. protected _buildBlock(state: NodeMaterialBuildState): this;
  59276. }
  59277. }
  59278. declare module BABYLON {
  59279. /**
  59280. * Block used to scale a vector by a float
  59281. */
  59282. export class ScaleBlock extends NodeMaterialBlock {
  59283. /**
  59284. * Creates a new ScaleBlock
  59285. * @param name defines the block name
  59286. */
  59287. constructor(name: string);
  59288. /**
  59289. * Gets the current class name
  59290. * @returns the class name
  59291. */
  59292. getClassName(): string;
  59293. /**
  59294. * Gets the input component
  59295. */
  59296. get input(): NodeMaterialConnectionPoint;
  59297. /**
  59298. * Gets the factor input component
  59299. */
  59300. get factor(): NodeMaterialConnectionPoint;
  59301. /**
  59302. * Gets the output component
  59303. */
  59304. get output(): NodeMaterialConnectionPoint;
  59305. protected _buildBlock(state: NodeMaterialBuildState): this;
  59306. }
  59307. }
  59308. declare module BABYLON {
  59309. /**
  59310. * Block used to clamp a float
  59311. */
  59312. export class ClampBlock extends NodeMaterialBlock {
  59313. /** Gets or sets the minimum range */
  59314. minimum: number;
  59315. /** Gets or sets the maximum range */
  59316. maximum: number;
  59317. /**
  59318. * Creates a new ClampBlock
  59319. * @param name defines the block name
  59320. */
  59321. constructor(name: string);
  59322. /**
  59323. * Gets the current class name
  59324. * @returns the class name
  59325. */
  59326. getClassName(): string;
  59327. /**
  59328. * Gets the value input component
  59329. */
  59330. get value(): NodeMaterialConnectionPoint;
  59331. /**
  59332. * Gets the output component
  59333. */
  59334. get output(): NodeMaterialConnectionPoint;
  59335. protected _buildBlock(state: NodeMaterialBuildState): this;
  59336. protected _dumpPropertiesCode(): string;
  59337. serialize(): any;
  59338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59339. }
  59340. }
  59341. declare module BABYLON {
  59342. /**
  59343. * Block used to apply a cross product between 2 vectors
  59344. */
  59345. export class CrossBlock extends NodeMaterialBlock {
  59346. /**
  59347. * Creates a new CrossBlock
  59348. * @param name defines the block name
  59349. */
  59350. constructor(name: string);
  59351. /**
  59352. * Gets the current class name
  59353. * @returns the class name
  59354. */
  59355. getClassName(): string;
  59356. /**
  59357. * Gets the left operand input component
  59358. */
  59359. get left(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the right operand input component
  59362. */
  59363. get right(): NodeMaterialConnectionPoint;
  59364. /**
  59365. * Gets the output component
  59366. */
  59367. get output(): NodeMaterialConnectionPoint;
  59368. protected _buildBlock(state: NodeMaterialBuildState): this;
  59369. }
  59370. }
  59371. declare module BABYLON {
  59372. /**
  59373. * Block used to apply a dot product between 2 vectors
  59374. */
  59375. export class DotBlock extends NodeMaterialBlock {
  59376. /**
  59377. * Creates a new DotBlock
  59378. * @param name defines the block name
  59379. */
  59380. constructor(name: string);
  59381. /**
  59382. * Gets the current class name
  59383. * @returns the class name
  59384. */
  59385. getClassName(): string;
  59386. /**
  59387. * Gets the left operand input component
  59388. */
  59389. get left(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the right operand input component
  59392. */
  59393. get right(): NodeMaterialConnectionPoint;
  59394. /**
  59395. * Gets the output component
  59396. */
  59397. get output(): NodeMaterialConnectionPoint;
  59398. protected _buildBlock(state: NodeMaterialBuildState): this;
  59399. }
  59400. }
  59401. declare module BABYLON {
  59402. /**
  59403. * Block used to remap a float from a range to a new one
  59404. */
  59405. export class RemapBlock extends NodeMaterialBlock {
  59406. /**
  59407. * Gets or sets the source range
  59408. */
  59409. sourceRange: Vector2;
  59410. /**
  59411. * Gets or sets the target range
  59412. */
  59413. targetRange: Vector2;
  59414. /**
  59415. * Creates a new RemapBlock
  59416. * @param name defines the block name
  59417. */
  59418. constructor(name: string);
  59419. /**
  59420. * Gets the current class name
  59421. * @returns the class name
  59422. */
  59423. getClassName(): string;
  59424. /**
  59425. * Gets the input component
  59426. */
  59427. get input(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the source min input component
  59430. */
  59431. get sourceMin(): NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the source max input component
  59434. */
  59435. get sourceMax(): NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the target min input component
  59438. */
  59439. get targetMin(): NodeMaterialConnectionPoint;
  59440. /**
  59441. * Gets the target max input component
  59442. */
  59443. get targetMax(): NodeMaterialConnectionPoint;
  59444. /**
  59445. * Gets the output component
  59446. */
  59447. get output(): NodeMaterialConnectionPoint;
  59448. protected _buildBlock(state: NodeMaterialBuildState): this;
  59449. protected _dumpPropertiesCode(): string;
  59450. serialize(): any;
  59451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59452. }
  59453. }
  59454. declare module BABYLON {
  59455. /**
  59456. * Block used to normalize a vector
  59457. */
  59458. export class NormalizeBlock extends NodeMaterialBlock {
  59459. /**
  59460. * Creates a new NormalizeBlock
  59461. * @param name defines the block name
  59462. */
  59463. constructor(name: string);
  59464. /**
  59465. * Gets the current class name
  59466. * @returns the class name
  59467. */
  59468. getClassName(): string;
  59469. /**
  59470. * Gets the input component
  59471. */
  59472. get input(): NodeMaterialConnectionPoint;
  59473. /**
  59474. * Gets the output component
  59475. */
  59476. get output(): NodeMaterialConnectionPoint;
  59477. protected _buildBlock(state: NodeMaterialBuildState): this;
  59478. }
  59479. }
  59480. declare module BABYLON {
  59481. /**
  59482. * Operations supported by the Trigonometry block
  59483. */
  59484. export enum TrigonometryBlockOperations {
  59485. /** Cos */
  59486. Cos = 0,
  59487. /** Sin */
  59488. Sin = 1,
  59489. /** Abs */
  59490. Abs = 2,
  59491. /** Exp */
  59492. Exp = 3,
  59493. /** Exp2 */
  59494. Exp2 = 4,
  59495. /** Round */
  59496. Round = 5,
  59497. /** Floor */
  59498. Floor = 6,
  59499. /** Ceiling */
  59500. Ceiling = 7,
  59501. /** Square root */
  59502. Sqrt = 8,
  59503. /** Log */
  59504. Log = 9,
  59505. /** Tangent */
  59506. Tan = 10,
  59507. /** Arc tangent */
  59508. ArcTan = 11,
  59509. /** Arc cosinus */
  59510. ArcCos = 12,
  59511. /** Arc sinus */
  59512. ArcSin = 13,
  59513. /** Fraction */
  59514. Fract = 14,
  59515. /** Sign */
  59516. Sign = 15,
  59517. /** To radians (from degrees) */
  59518. Radians = 16,
  59519. /** To degrees (from radians) */
  59520. Degrees = 17
  59521. }
  59522. /**
  59523. * Block used to apply trigonometry operation to floats
  59524. */
  59525. export class TrigonometryBlock extends NodeMaterialBlock {
  59526. /**
  59527. * Gets or sets the operation applied by the block
  59528. */
  59529. operation: TrigonometryBlockOperations;
  59530. /**
  59531. * Creates a new TrigonometryBlock
  59532. * @param name defines the block name
  59533. */
  59534. constructor(name: string);
  59535. /**
  59536. * Gets the current class name
  59537. * @returns the class name
  59538. */
  59539. getClassName(): string;
  59540. /**
  59541. * Gets the input component
  59542. */
  59543. get input(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the output component
  59546. */
  59547. get output(): NodeMaterialConnectionPoint;
  59548. protected _buildBlock(state: NodeMaterialBuildState): this;
  59549. serialize(): any;
  59550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59551. protected _dumpPropertiesCode(): string;
  59552. }
  59553. }
  59554. declare module BABYLON {
  59555. /**
  59556. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59557. */
  59558. export class ColorMergerBlock extends NodeMaterialBlock {
  59559. /**
  59560. * Create a new ColorMergerBlock
  59561. * @param name defines the block name
  59562. */
  59563. constructor(name: string);
  59564. /**
  59565. * Gets the current class name
  59566. * @returns the class name
  59567. */
  59568. getClassName(): string;
  59569. /**
  59570. * Gets the rgb component (input)
  59571. */
  59572. get rgbIn(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the r component (input)
  59575. */
  59576. get r(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the g component (input)
  59579. */
  59580. get g(): NodeMaterialConnectionPoint;
  59581. /**
  59582. * Gets the b component (input)
  59583. */
  59584. get b(): NodeMaterialConnectionPoint;
  59585. /**
  59586. * Gets the a component (input)
  59587. */
  59588. get a(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the rgba component (output)
  59591. */
  59592. get rgba(): NodeMaterialConnectionPoint;
  59593. /**
  59594. * Gets the rgb component (output)
  59595. */
  59596. get rgbOut(): NodeMaterialConnectionPoint;
  59597. /**
  59598. * Gets the rgb component (output)
  59599. * @deprecated Please use rgbOut instead.
  59600. */
  59601. get rgb(): NodeMaterialConnectionPoint;
  59602. protected _buildBlock(state: NodeMaterialBuildState): this;
  59603. }
  59604. }
  59605. declare module BABYLON {
  59606. /**
  59607. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59608. */
  59609. export class VectorMergerBlock extends NodeMaterialBlock {
  59610. /**
  59611. * Create a new VectorMergerBlock
  59612. * @param name defines the block name
  59613. */
  59614. constructor(name: string);
  59615. /**
  59616. * Gets the current class name
  59617. * @returns the class name
  59618. */
  59619. getClassName(): string;
  59620. /**
  59621. * Gets the xyz component (input)
  59622. */
  59623. get xyzIn(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the xy component (input)
  59626. */
  59627. get xyIn(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the x component (input)
  59630. */
  59631. get x(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the y component (input)
  59634. */
  59635. get y(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the z component (input)
  59638. */
  59639. get z(): NodeMaterialConnectionPoint;
  59640. /**
  59641. * Gets the w component (input)
  59642. */
  59643. get w(): NodeMaterialConnectionPoint;
  59644. /**
  59645. * Gets the xyzw component (output)
  59646. */
  59647. get xyzw(): NodeMaterialConnectionPoint;
  59648. /**
  59649. * Gets the xyz component (output)
  59650. */
  59651. get xyzOut(): NodeMaterialConnectionPoint;
  59652. /**
  59653. * Gets the xy component (output)
  59654. */
  59655. get xyOut(): NodeMaterialConnectionPoint;
  59656. /**
  59657. * Gets the xy component (output)
  59658. * @deprecated Please use xyOut instead.
  59659. */
  59660. get xy(): NodeMaterialConnectionPoint;
  59661. /**
  59662. * Gets the xyz component (output)
  59663. * @deprecated Please use xyzOut instead.
  59664. */
  59665. get xyz(): NodeMaterialConnectionPoint;
  59666. protected _buildBlock(state: NodeMaterialBuildState): this;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59672. */
  59673. export class ColorSplitterBlock extends NodeMaterialBlock {
  59674. /**
  59675. * Create a new ColorSplitterBlock
  59676. * @param name defines the block name
  59677. */
  59678. constructor(name: string);
  59679. /**
  59680. * Gets the current class name
  59681. * @returns the class name
  59682. */
  59683. getClassName(): string;
  59684. /**
  59685. * Gets the rgba component (input)
  59686. */
  59687. get rgba(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the rgb component (input)
  59690. */
  59691. get rgbIn(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the rgb component (output)
  59694. */
  59695. get rgbOut(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the r component (output)
  59698. */
  59699. get r(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the g component (output)
  59702. */
  59703. get g(): NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the b component (output)
  59706. */
  59707. get b(): NodeMaterialConnectionPoint;
  59708. /**
  59709. * Gets the a component (output)
  59710. */
  59711. get a(): NodeMaterialConnectionPoint;
  59712. protected _inputRename(name: string): string;
  59713. protected _outputRename(name: string): string;
  59714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59715. }
  59716. }
  59717. declare module BABYLON {
  59718. /**
  59719. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59720. */
  59721. export class VectorSplitterBlock extends NodeMaterialBlock {
  59722. /**
  59723. * Create a new VectorSplitterBlock
  59724. * @param name defines the block name
  59725. */
  59726. constructor(name: string);
  59727. /**
  59728. * Gets the current class name
  59729. * @returns the class name
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Gets the xyzw component (input)
  59734. */
  59735. get xyzw(): NodeMaterialConnectionPoint;
  59736. /**
  59737. * Gets the xyz component (input)
  59738. */
  59739. get xyzIn(): NodeMaterialConnectionPoint;
  59740. /**
  59741. * Gets the xy component (input)
  59742. */
  59743. get xyIn(): NodeMaterialConnectionPoint;
  59744. /**
  59745. * Gets the xyz component (output)
  59746. */
  59747. get xyzOut(): NodeMaterialConnectionPoint;
  59748. /**
  59749. * Gets the xy component (output)
  59750. */
  59751. get xyOut(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the x component (output)
  59754. */
  59755. get x(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the y component (output)
  59758. */
  59759. get y(): NodeMaterialConnectionPoint;
  59760. /**
  59761. * Gets the z component (output)
  59762. */
  59763. get z(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the w component (output)
  59766. */
  59767. get w(): NodeMaterialConnectionPoint;
  59768. protected _inputRename(name: string): string;
  59769. protected _outputRename(name: string): string;
  59770. protected _buildBlock(state: NodeMaterialBuildState): this;
  59771. }
  59772. }
  59773. declare module BABYLON {
  59774. /**
  59775. * Block used to lerp between 2 values
  59776. */
  59777. export class LerpBlock extends NodeMaterialBlock {
  59778. /**
  59779. * Creates a new LerpBlock
  59780. * @param name defines the block name
  59781. */
  59782. constructor(name: string);
  59783. /**
  59784. * Gets the current class name
  59785. * @returns the class name
  59786. */
  59787. getClassName(): string;
  59788. /**
  59789. * Gets the left operand input component
  59790. */
  59791. get left(): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Gets the right operand input component
  59794. */
  59795. get right(): NodeMaterialConnectionPoint;
  59796. /**
  59797. * Gets the gradient operand input component
  59798. */
  59799. get gradient(): NodeMaterialConnectionPoint;
  59800. /**
  59801. * Gets the output component
  59802. */
  59803. get output(): NodeMaterialConnectionPoint;
  59804. protected _buildBlock(state: NodeMaterialBuildState): this;
  59805. }
  59806. }
  59807. declare module BABYLON {
  59808. /**
  59809. * Block used to divide 2 vectors
  59810. */
  59811. export class DivideBlock extends NodeMaterialBlock {
  59812. /**
  59813. * Creates a new DivideBlock
  59814. * @param name defines the block name
  59815. */
  59816. constructor(name: string);
  59817. /**
  59818. * Gets the current class name
  59819. * @returns the class name
  59820. */
  59821. getClassName(): string;
  59822. /**
  59823. * Gets the left operand input component
  59824. */
  59825. get left(): NodeMaterialConnectionPoint;
  59826. /**
  59827. * Gets the right operand input component
  59828. */
  59829. get right(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the output component
  59832. */
  59833. get output(): NodeMaterialConnectionPoint;
  59834. protected _buildBlock(state: NodeMaterialBuildState): this;
  59835. }
  59836. }
  59837. declare module BABYLON {
  59838. /**
  59839. * Block used to subtract 2 vectors
  59840. */
  59841. export class SubtractBlock extends NodeMaterialBlock {
  59842. /**
  59843. * Creates a new SubtractBlock
  59844. * @param name defines the block name
  59845. */
  59846. constructor(name: string);
  59847. /**
  59848. * Gets the current class name
  59849. * @returns the class name
  59850. */
  59851. getClassName(): string;
  59852. /**
  59853. * Gets the left operand input component
  59854. */
  59855. get left(): NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the right operand input component
  59858. */
  59859. get right(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the output component
  59862. */
  59863. get output(): NodeMaterialConnectionPoint;
  59864. protected _buildBlock(state: NodeMaterialBuildState): this;
  59865. }
  59866. }
  59867. declare module BABYLON {
  59868. /**
  59869. * Block used to step a value
  59870. */
  59871. export class StepBlock extends NodeMaterialBlock {
  59872. /**
  59873. * Creates a new StepBlock
  59874. * @param name defines the block name
  59875. */
  59876. constructor(name: string);
  59877. /**
  59878. * Gets the current class name
  59879. * @returns the class name
  59880. */
  59881. getClassName(): string;
  59882. /**
  59883. * Gets the value operand input component
  59884. */
  59885. get value(): NodeMaterialConnectionPoint;
  59886. /**
  59887. * Gets the edge operand input component
  59888. */
  59889. get edge(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the output component
  59892. */
  59893. get output(): NodeMaterialConnectionPoint;
  59894. protected _buildBlock(state: NodeMaterialBuildState): this;
  59895. }
  59896. }
  59897. declare module BABYLON {
  59898. /**
  59899. * Block used to get the opposite (1 - x) of a value
  59900. */
  59901. export class OneMinusBlock extends NodeMaterialBlock {
  59902. /**
  59903. * Creates a new OneMinusBlock
  59904. * @param name defines the block name
  59905. */
  59906. constructor(name: string);
  59907. /**
  59908. * Gets the current class name
  59909. * @returns the class name
  59910. */
  59911. getClassName(): string;
  59912. /**
  59913. * Gets the input component
  59914. */
  59915. get input(): NodeMaterialConnectionPoint;
  59916. /**
  59917. * Gets the output component
  59918. */
  59919. get output(): NodeMaterialConnectionPoint;
  59920. protected _buildBlock(state: NodeMaterialBuildState): this;
  59921. }
  59922. }
  59923. declare module BABYLON {
  59924. /**
  59925. * Block used to get the view direction
  59926. */
  59927. export class ViewDirectionBlock extends NodeMaterialBlock {
  59928. /**
  59929. * Creates a new ViewDirectionBlock
  59930. * @param name defines the block name
  59931. */
  59932. constructor(name: string);
  59933. /**
  59934. * Gets the current class name
  59935. * @returns the class name
  59936. */
  59937. getClassName(): string;
  59938. /**
  59939. * Gets the world position component
  59940. */
  59941. get worldPosition(): NodeMaterialConnectionPoint;
  59942. /**
  59943. * Gets the camera position component
  59944. */
  59945. get cameraPosition(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the output component
  59948. */
  59949. get output(): NodeMaterialConnectionPoint;
  59950. autoConfigure(material: NodeMaterial): void;
  59951. protected _buildBlock(state: NodeMaterialBuildState): this;
  59952. }
  59953. }
  59954. declare module BABYLON {
  59955. /**
  59956. * Block used to compute fresnel value
  59957. */
  59958. export class FresnelBlock extends NodeMaterialBlock {
  59959. /**
  59960. * Create a new FresnelBlock
  59961. * @param name defines the block name
  59962. */
  59963. constructor(name: string);
  59964. /**
  59965. * Gets the current class name
  59966. * @returns the class name
  59967. */
  59968. getClassName(): string;
  59969. /**
  59970. * Gets the world normal input component
  59971. */
  59972. get worldNormal(): NodeMaterialConnectionPoint;
  59973. /**
  59974. * Gets the view direction input component
  59975. */
  59976. get viewDirection(): NodeMaterialConnectionPoint;
  59977. /**
  59978. * Gets the bias input component
  59979. */
  59980. get bias(): NodeMaterialConnectionPoint;
  59981. /**
  59982. * Gets the camera (or eye) position component
  59983. */
  59984. get power(): NodeMaterialConnectionPoint;
  59985. /**
  59986. * Gets the fresnel output component
  59987. */
  59988. get fresnel(): NodeMaterialConnectionPoint;
  59989. autoConfigure(material: NodeMaterial): void;
  59990. protected _buildBlock(state: NodeMaterialBuildState): this;
  59991. }
  59992. }
  59993. declare module BABYLON {
  59994. /**
  59995. * Block used to get the max of 2 values
  59996. */
  59997. export class MaxBlock extends NodeMaterialBlock {
  59998. /**
  59999. * Creates a new MaxBlock
  60000. * @param name defines the block name
  60001. */
  60002. constructor(name: string);
  60003. /**
  60004. * Gets the current class name
  60005. * @returns the class name
  60006. */
  60007. getClassName(): string;
  60008. /**
  60009. * Gets the left operand input component
  60010. */
  60011. get left(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the right operand input component
  60014. */
  60015. get right(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the output component
  60018. */
  60019. get output(): NodeMaterialConnectionPoint;
  60020. protected _buildBlock(state: NodeMaterialBuildState): this;
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. /**
  60025. * Block used to get the min of 2 values
  60026. */
  60027. export class MinBlock extends NodeMaterialBlock {
  60028. /**
  60029. * Creates a new MinBlock
  60030. * @param name defines the block name
  60031. */
  60032. constructor(name: string);
  60033. /**
  60034. * Gets the current class name
  60035. * @returns the class name
  60036. */
  60037. getClassName(): string;
  60038. /**
  60039. * Gets the left operand input component
  60040. */
  60041. get left(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the right operand input component
  60044. */
  60045. get right(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the output component
  60048. */
  60049. get output(): NodeMaterialConnectionPoint;
  60050. protected _buildBlock(state: NodeMaterialBuildState): this;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. /**
  60055. * Block used to get the distance between 2 values
  60056. */
  60057. export class DistanceBlock extends NodeMaterialBlock {
  60058. /**
  60059. * Creates a new DistanceBlock
  60060. * @param name defines the block name
  60061. */
  60062. constructor(name: string);
  60063. /**
  60064. * Gets the current class name
  60065. * @returns the class name
  60066. */
  60067. getClassName(): string;
  60068. /**
  60069. * Gets the left operand input component
  60070. */
  60071. get left(): NodeMaterialConnectionPoint;
  60072. /**
  60073. * Gets the right operand input component
  60074. */
  60075. get right(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the output component
  60078. */
  60079. get output(): NodeMaterialConnectionPoint;
  60080. protected _buildBlock(state: NodeMaterialBuildState): this;
  60081. }
  60082. }
  60083. declare module BABYLON {
  60084. /**
  60085. * Block used to get the length of a vector
  60086. */
  60087. export class LengthBlock extends NodeMaterialBlock {
  60088. /**
  60089. * Creates a new LengthBlock
  60090. * @param name defines the block name
  60091. */
  60092. constructor(name: string);
  60093. /**
  60094. * Gets the current class name
  60095. * @returns the class name
  60096. */
  60097. getClassName(): string;
  60098. /**
  60099. * Gets the value input component
  60100. */
  60101. get value(): NodeMaterialConnectionPoint;
  60102. /**
  60103. * Gets the output component
  60104. */
  60105. get output(): NodeMaterialConnectionPoint;
  60106. protected _buildBlock(state: NodeMaterialBuildState): this;
  60107. }
  60108. }
  60109. declare module BABYLON {
  60110. /**
  60111. * Block used to get negative version of a value (i.e. x * -1)
  60112. */
  60113. export class NegateBlock extends NodeMaterialBlock {
  60114. /**
  60115. * Creates a new NegateBlock
  60116. * @param name defines the block name
  60117. */
  60118. constructor(name: string);
  60119. /**
  60120. * Gets the current class name
  60121. * @returns the class name
  60122. */
  60123. getClassName(): string;
  60124. /**
  60125. * Gets the value input component
  60126. */
  60127. get value(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the output component
  60130. */
  60131. get output(): NodeMaterialConnectionPoint;
  60132. protected _buildBlock(state: NodeMaterialBuildState): this;
  60133. }
  60134. }
  60135. declare module BABYLON {
  60136. /**
  60137. * Block used to get the value of the first parameter raised to the power of the second
  60138. */
  60139. export class PowBlock extends NodeMaterialBlock {
  60140. /**
  60141. * Creates a new PowBlock
  60142. * @param name defines the block name
  60143. */
  60144. constructor(name: string);
  60145. /**
  60146. * Gets the current class name
  60147. * @returns the class name
  60148. */
  60149. getClassName(): string;
  60150. /**
  60151. * Gets the value operand input component
  60152. */
  60153. get value(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the power operand input component
  60156. */
  60157. get power(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the output component
  60160. */
  60161. get output(): NodeMaterialConnectionPoint;
  60162. protected _buildBlock(state: NodeMaterialBuildState): this;
  60163. }
  60164. }
  60165. declare module BABYLON {
  60166. /**
  60167. * Block used to get a random number
  60168. */
  60169. export class RandomNumberBlock extends NodeMaterialBlock {
  60170. /**
  60171. * Creates a new RandomNumberBlock
  60172. * @param name defines the block name
  60173. */
  60174. constructor(name: string);
  60175. /**
  60176. * Gets the current class name
  60177. * @returns the class name
  60178. */
  60179. getClassName(): string;
  60180. /**
  60181. * Gets the seed input component
  60182. */
  60183. get seed(): NodeMaterialConnectionPoint;
  60184. /**
  60185. * Gets the output component
  60186. */
  60187. get output(): NodeMaterialConnectionPoint;
  60188. protected _buildBlock(state: NodeMaterialBuildState): this;
  60189. }
  60190. }
  60191. declare module BABYLON {
  60192. /**
  60193. * Block used to compute arc tangent of 2 values
  60194. */
  60195. export class ArcTan2Block extends NodeMaterialBlock {
  60196. /**
  60197. * Creates a new ArcTan2Block
  60198. * @param name defines the block name
  60199. */
  60200. constructor(name: string);
  60201. /**
  60202. * Gets the current class name
  60203. * @returns the class name
  60204. */
  60205. getClassName(): string;
  60206. /**
  60207. * Gets the x operand input component
  60208. */
  60209. get x(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the y operand input component
  60212. */
  60213. get y(): NodeMaterialConnectionPoint;
  60214. /**
  60215. * Gets the output component
  60216. */
  60217. get output(): NodeMaterialConnectionPoint;
  60218. protected _buildBlock(state: NodeMaterialBuildState): this;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Block used to smooth step a value
  60224. */
  60225. export class SmoothStepBlock extends NodeMaterialBlock {
  60226. /**
  60227. * Creates a new SmoothStepBlock
  60228. * @param name defines the block name
  60229. */
  60230. constructor(name: string);
  60231. /**
  60232. * Gets the current class name
  60233. * @returns the class name
  60234. */
  60235. getClassName(): string;
  60236. /**
  60237. * Gets the value operand input component
  60238. */
  60239. get value(): NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the first edge operand input component
  60242. */
  60243. get edge0(): NodeMaterialConnectionPoint;
  60244. /**
  60245. * Gets the second edge operand input component
  60246. */
  60247. get edge1(): NodeMaterialConnectionPoint;
  60248. /**
  60249. * Gets the output component
  60250. */
  60251. get output(): NodeMaterialConnectionPoint;
  60252. protected _buildBlock(state: NodeMaterialBuildState): this;
  60253. }
  60254. }
  60255. declare module BABYLON {
  60256. /**
  60257. * Block used to get the reciprocal (1 / x) of a value
  60258. */
  60259. export class ReciprocalBlock extends NodeMaterialBlock {
  60260. /**
  60261. * Creates a new ReciprocalBlock
  60262. * @param name defines the block name
  60263. */
  60264. constructor(name: string);
  60265. /**
  60266. * Gets the current class name
  60267. * @returns the class name
  60268. */
  60269. getClassName(): string;
  60270. /**
  60271. * Gets the input component
  60272. */
  60273. get input(): NodeMaterialConnectionPoint;
  60274. /**
  60275. * Gets the output component
  60276. */
  60277. get output(): NodeMaterialConnectionPoint;
  60278. protected _buildBlock(state: NodeMaterialBuildState): this;
  60279. }
  60280. }
  60281. declare module BABYLON {
  60282. /**
  60283. * Block used to replace a color by another one
  60284. */
  60285. export class ReplaceColorBlock extends NodeMaterialBlock {
  60286. /**
  60287. * Creates a new ReplaceColorBlock
  60288. * @param name defines the block name
  60289. */
  60290. constructor(name: string);
  60291. /**
  60292. * Gets the current class name
  60293. * @returns the class name
  60294. */
  60295. getClassName(): string;
  60296. /**
  60297. * Gets the value input component
  60298. */
  60299. get value(): NodeMaterialConnectionPoint;
  60300. /**
  60301. * Gets the reference input component
  60302. */
  60303. get reference(): NodeMaterialConnectionPoint;
  60304. /**
  60305. * Gets the distance input component
  60306. */
  60307. get distance(): NodeMaterialConnectionPoint;
  60308. /**
  60309. * Gets the replacement input component
  60310. */
  60311. get replacement(): NodeMaterialConnectionPoint;
  60312. /**
  60313. * Gets the output component
  60314. */
  60315. get output(): NodeMaterialConnectionPoint;
  60316. protected _buildBlock(state: NodeMaterialBuildState): this;
  60317. }
  60318. }
  60319. declare module BABYLON {
  60320. /**
  60321. * Block used to posterize a value
  60322. * @see https://en.wikipedia.org/wiki/Posterization
  60323. */
  60324. export class PosterizeBlock extends NodeMaterialBlock {
  60325. /**
  60326. * Creates a new PosterizeBlock
  60327. * @param name defines the block name
  60328. */
  60329. constructor(name: string);
  60330. /**
  60331. * Gets the current class name
  60332. * @returns the class name
  60333. */
  60334. getClassName(): string;
  60335. /**
  60336. * Gets the value input component
  60337. */
  60338. get value(): NodeMaterialConnectionPoint;
  60339. /**
  60340. * Gets the steps input component
  60341. */
  60342. get steps(): NodeMaterialConnectionPoint;
  60343. /**
  60344. * Gets the output component
  60345. */
  60346. get output(): NodeMaterialConnectionPoint;
  60347. protected _buildBlock(state: NodeMaterialBuildState): this;
  60348. }
  60349. }
  60350. declare module BABYLON {
  60351. /**
  60352. * Operations supported by the Wave block
  60353. */
  60354. export enum WaveBlockKind {
  60355. /** SawTooth */
  60356. SawTooth = 0,
  60357. /** Square */
  60358. Square = 1,
  60359. /** Triangle */
  60360. Triangle = 2
  60361. }
  60362. /**
  60363. * Block used to apply wave operation to floats
  60364. */
  60365. export class WaveBlock extends NodeMaterialBlock {
  60366. /**
  60367. * Gets or sets the kibnd of wave to be applied by the block
  60368. */
  60369. kind: WaveBlockKind;
  60370. /**
  60371. * Creates a new WaveBlock
  60372. * @param name defines the block name
  60373. */
  60374. constructor(name: string);
  60375. /**
  60376. * Gets the current class name
  60377. * @returns the class name
  60378. */
  60379. getClassName(): string;
  60380. /**
  60381. * Gets the input component
  60382. */
  60383. get input(): NodeMaterialConnectionPoint;
  60384. /**
  60385. * Gets the output component
  60386. */
  60387. get output(): NodeMaterialConnectionPoint;
  60388. protected _buildBlock(state: NodeMaterialBuildState): this;
  60389. serialize(): any;
  60390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60391. }
  60392. }
  60393. declare module BABYLON {
  60394. /**
  60395. * Class used to store a color step for the GradientBlock
  60396. */
  60397. export class GradientBlockColorStep {
  60398. /**
  60399. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60400. */
  60401. step: number;
  60402. /**
  60403. * Gets or sets the color associated with this step
  60404. */
  60405. color: Color3;
  60406. /**
  60407. * Creates a new GradientBlockColorStep
  60408. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60409. * @param color defines the color associated with this step
  60410. */
  60411. constructor(
  60412. /**
  60413. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60414. */
  60415. step: number,
  60416. /**
  60417. * Gets or sets the color associated with this step
  60418. */
  60419. color: Color3);
  60420. }
  60421. /**
  60422. * Block used to return a color from a gradient based on an input value between 0 and 1
  60423. */
  60424. export class GradientBlock extends NodeMaterialBlock {
  60425. /**
  60426. * Gets or sets the list of color steps
  60427. */
  60428. colorSteps: GradientBlockColorStep[];
  60429. /**
  60430. * Creates a new GradientBlock
  60431. * @param name defines the block name
  60432. */
  60433. constructor(name: string);
  60434. /**
  60435. * Gets the current class name
  60436. * @returns the class name
  60437. */
  60438. getClassName(): string;
  60439. /**
  60440. * Gets the gradient input component
  60441. */
  60442. get gradient(): NodeMaterialConnectionPoint;
  60443. /**
  60444. * Gets the output component
  60445. */
  60446. get output(): NodeMaterialConnectionPoint;
  60447. private _writeColorConstant;
  60448. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60449. serialize(): any;
  60450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60451. protected _dumpPropertiesCode(): string;
  60452. }
  60453. }
  60454. declare module BABYLON {
  60455. /**
  60456. * Block used to normalize lerp between 2 values
  60457. */
  60458. export class NLerpBlock extends NodeMaterialBlock {
  60459. /**
  60460. * Creates a new NLerpBlock
  60461. * @param name defines the block name
  60462. */
  60463. constructor(name: string);
  60464. /**
  60465. * Gets the current class name
  60466. * @returns the class name
  60467. */
  60468. getClassName(): string;
  60469. /**
  60470. * Gets the left operand input component
  60471. */
  60472. get left(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the right operand input component
  60475. */
  60476. get right(): NodeMaterialConnectionPoint;
  60477. /**
  60478. * Gets the gradient operand input component
  60479. */
  60480. get gradient(): NodeMaterialConnectionPoint;
  60481. /**
  60482. * Gets the output component
  60483. */
  60484. get output(): NodeMaterialConnectionPoint;
  60485. protected _buildBlock(state: NodeMaterialBuildState): this;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * block used to Generate a Worley Noise 3D Noise Pattern
  60491. */
  60492. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60493. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60494. manhattanDistance: boolean;
  60495. /**
  60496. * Creates a new WorleyNoise3DBlock
  60497. * @param name defines the block name
  60498. */
  60499. constructor(name: string);
  60500. /**
  60501. * Gets the current class name
  60502. * @returns the class name
  60503. */
  60504. getClassName(): string;
  60505. /**
  60506. * Gets the seed input component
  60507. */
  60508. get seed(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the jitter input component
  60511. */
  60512. get jitter(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the output component
  60515. */
  60516. get output(): NodeMaterialConnectionPoint;
  60517. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60518. /**
  60519. * Exposes the properties to the UI?
  60520. */
  60521. protected _dumpPropertiesCode(): string;
  60522. /**
  60523. * Exposes the properties to the Seralize?
  60524. */
  60525. serialize(): any;
  60526. /**
  60527. * Exposes the properties to the deseralize?
  60528. */
  60529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60530. }
  60531. }
  60532. declare module BABYLON {
  60533. /**
  60534. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60535. */
  60536. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60537. /**
  60538. * Creates a new SimplexPerlin3DBlock
  60539. * @param name defines the block name
  60540. */
  60541. constructor(name: string);
  60542. /**
  60543. * Gets the current class name
  60544. * @returns the class name
  60545. */
  60546. getClassName(): string;
  60547. /**
  60548. * Gets the seed operand input component
  60549. */
  60550. get seed(): NodeMaterialConnectionPoint;
  60551. /**
  60552. * Gets the output component
  60553. */
  60554. get output(): NodeMaterialConnectionPoint;
  60555. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60556. }
  60557. }
  60558. declare module BABYLON {
  60559. /**
  60560. * Block used to blend normals
  60561. */
  60562. export class NormalBlendBlock extends NodeMaterialBlock {
  60563. /**
  60564. * Creates a new NormalBlendBlock
  60565. * @param name defines the block name
  60566. */
  60567. constructor(name: string);
  60568. /**
  60569. * Gets the current class name
  60570. * @returns the class name
  60571. */
  60572. getClassName(): string;
  60573. /**
  60574. * Gets the first input component
  60575. */
  60576. get normalMap0(): NodeMaterialConnectionPoint;
  60577. /**
  60578. * Gets the second input component
  60579. */
  60580. get normalMap1(): NodeMaterialConnectionPoint;
  60581. /**
  60582. * Gets the output component
  60583. */
  60584. get output(): NodeMaterialConnectionPoint;
  60585. protected _buildBlock(state: NodeMaterialBuildState): this;
  60586. }
  60587. }
  60588. declare module BABYLON {
  60589. /**
  60590. * Block used to rotate a 2d vector by a given angle
  60591. */
  60592. export class Rotate2dBlock extends NodeMaterialBlock {
  60593. /**
  60594. * Creates a new Rotate2dBlock
  60595. * @param name defines the block name
  60596. */
  60597. constructor(name: string);
  60598. /**
  60599. * Gets the current class name
  60600. * @returns the class name
  60601. */
  60602. getClassName(): string;
  60603. /**
  60604. * Gets the input vector
  60605. */
  60606. get input(): NodeMaterialConnectionPoint;
  60607. /**
  60608. * Gets the input angle
  60609. */
  60610. get angle(): NodeMaterialConnectionPoint;
  60611. /**
  60612. * Gets the output component
  60613. */
  60614. get output(): NodeMaterialConnectionPoint;
  60615. autoConfigure(material: NodeMaterial): void;
  60616. protected _buildBlock(state: NodeMaterialBuildState): this;
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * Block used to get the reflected vector from a direction and a normal
  60622. */
  60623. export class ReflectBlock extends NodeMaterialBlock {
  60624. /**
  60625. * Creates a new ReflectBlock
  60626. * @param name defines the block name
  60627. */
  60628. constructor(name: string);
  60629. /**
  60630. * Gets the current class name
  60631. * @returns the class name
  60632. */
  60633. getClassName(): string;
  60634. /**
  60635. * Gets the incident component
  60636. */
  60637. get incident(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Gets the normal component
  60640. */
  60641. get normal(): NodeMaterialConnectionPoint;
  60642. /**
  60643. * Gets the output component
  60644. */
  60645. get output(): NodeMaterialConnectionPoint;
  60646. protected _buildBlock(state: NodeMaterialBuildState): this;
  60647. }
  60648. }
  60649. declare module BABYLON {
  60650. /**
  60651. * Block used to get the refracted vector from a direction and a normal
  60652. */
  60653. export class RefractBlock extends NodeMaterialBlock {
  60654. /**
  60655. * Creates a new RefractBlock
  60656. * @param name defines the block name
  60657. */
  60658. constructor(name: string);
  60659. /**
  60660. * Gets the current class name
  60661. * @returns the class name
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Gets the incident component
  60666. */
  60667. get incident(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the normal component
  60670. */
  60671. get normal(): NodeMaterialConnectionPoint;
  60672. /**
  60673. * Gets the index of refraction component
  60674. */
  60675. get ior(): NodeMaterialConnectionPoint;
  60676. /**
  60677. * Gets the output component
  60678. */
  60679. get output(): NodeMaterialConnectionPoint;
  60680. protected _buildBlock(state: NodeMaterialBuildState): this;
  60681. }
  60682. }
  60683. declare module BABYLON {
  60684. /**
  60685. * Block used to desaturate a color
  60686. */
  60687. export class DesaturateBlock extends NodeMaterialBlock {
  60688. /**
  60689. * Creates a new DesaturateBlock
  60690. * @param name defines the block name
  60691. */
  60692. constructor(name: string);
  60693. /**
  60694. * Gets the current class name
  60695. * @returns the class name
  60696. */
  60697. getClassName(): string;
  60698. /**
  60699. * Gets the color operand input component
  60700. */
  60701. get color(): NodeMaterialConnectionPoint;
  60702. /**
  60703. * Gets the level operand input component
  60704. */
  60705. get level(): NodeMaterialConnectionPoint;
  60706. /**
  60707. * Gets the output component
  60708. */
  60709. get output(): NodeMaterialConnectionPoint;
  60710. protected _buildBlock(state: NodeMaterialBuildState): this;
  60711. }
  60712. }
  60713. declare module BABYLON {
  60714. /**
  60715. * Effect Render Options
  60716. */
  60717. export interface IEffectRendererOptions {
  60718. /**
  60719. * Defines the vertices positions.
  60720. */
  60721. positions?: number[];
  60722. /**
  60723. * Defines the indices.
  60724. */
  60725. indices?: number[];
  60726. }
  60727. /**
  60728. * Helper class to render one or more effects.
  60729. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60730. */
  60731. export class EffectRenderer {
  60732. private engine;
  60733. private static _DefaultOptions;
  60734. private _vertexBuffers;
  60735. private _indexBuffer;
  60736. private _fullscreenViewport;
  60737. /**
  60738. * Creates an effect renderer
  60739. * @param engine the engine to use for rendering
  60740. * @param options defines the options of the effect renderer
  60741. */
  60742. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60743. /**
  60744. * Sets the current viewport in normalized coordinates 0-1
  60745. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60746. */
  60747. setViewport(viewport?: Viewport): void;
  60748. /**
  60749. * Binds the embedded attributes buffer to the effect.
  60750. * @param effect Defines the effect to bind the attributes for
  60751. */
  60752. bindBuffers(effect: Effect): void;
  60753. /**
  60754. * Sets the current effect wrapper to use during draw.
  60755. * The effect needs to be ready before calling this api.
  60756. * This also sets the default full screen position attribute.
  60757. * @param effectWrapper Defines the effect to draw with
  60758. */
  60759. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60760. /**
  60761. * Draws a full screen quad.
  60762. */
  60763. draw(): void;
  60764. private isRenderTargetTexture;
  60765. /**
  60766. * renders one or more effects to a specified texture
  60767. * @param effectWrapper the effect to renderer
  60768. * @param outputTexture texture to draw to, if null it will render to the screen.
  60769. */
  60770. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60771. /**
  60772. * Disposes of the effect renderer
  60773. */
  60774. dispose(): void;
  60775. }
  60776. /**
  60777. * Options to create an EffectWrapper
  60778. */
  60779. interface EffectWrapperCreationOptions {
  60780. /**
  60781. * Engine to use to create the effect
  60782. */
  60783. engine: ThinEngine;
  60784. /**
  60785. * Fragment shader for the effect
  60786. */
  60787. fragmentShader: string;
  60788. /**
  60789. * Vertex shader for the effect
  60790. */
  60791. vertexShader?: string;
  60792. /**
  60793. * Attributes to use in the shader
  60794. */
  60795. attributeNames?: Array<string>;
  60796. /**
  60797. * Uniforms to use in the shader
  60798. */
  60799. uniformNames?: Array<string>;
  60800. /**
  60801. * Texture sampler names to use in the shader
  60802. */
  60803. samplerNames?: Array<string>;
  60804. /**
  60805. * The friendly name of the effect displayed in Spector.
  60806. */
  60807. name?: string;
  60808. }
  60809. /**
  60810. * Wraps an effect to be used for rendering
  60811. */
  60812. export class EffectWrapper {
  60813. /**
  60814. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60815. */
  60816. onApplyObservable: Observable<{}>;
  60817. /**
  60818. * The underlying effect
  60819. */
  60820. effect: Effect;
  60821. /**
  60822. * Creates an effect to be renderer
  60823. * @param creationOptions options to create the effect
  60824. */
  60825. constructor(creationOptions: EffectWrapperCreationOptions);
  60826. /**
  60827. * Disposes of the effect wrapper
  60828. */
  60829. dispose(): void;
  60830. }
  60831. }
  60832. declare module BABYLON {
  60833. /**
  60834. * Helper class to push actions to a pool of workers.
  60835. */
  60836. export class WorkerPool implements IDisposable {
  60837. private _workerInfos;
  60838. private _pendingActions;
  60839. /**
  60840. * Constructor
  60841. * @param workers Array of workers to use for actions
  60842. */
  60843. constructor(workers: Array<Worker>);
  60844. /**
  60845. * Terminates all workers and clears any pending actions.
  60846. */
  60847. dispose(): void;
  60848. /**
  60849. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60850. * pended until a worker has completed its action.
  60851. * @param action The action to perform. Call onComplete when the action is complete.
  60852. */
  60853. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60854. private _execute;
  60855. }
  60856. }
  60857. declare module BABYLON {
  60858. /**
  60859. * Configuration for Draco compression
  60860. */
  60861. export interface IDracoCompressionConfiguration {
  60862. /**
  60863. * Configuration for the decoder.
  60864. */
  60865. decoder: {
  60866. /**
  60867. * The url to the WebAssembly module.
  60868. */
  60869. wasmUrl?: string;
  60870. /**
  60871. * The url to the WebAssembly binary.
  60872. */
  60873. wasmBinaryUrl?: string;
  60874. /**
  60875. * The url to the fallback JavaScript module.
  60876. */
  60877. fallbackUrl?: string;
  60878. };
  60879. }
  60880. /**
  60881. * Draco compression (https://google.github.io/draco/)
  60882. *
  60883. * This class wraps the Draco module.
  60884. *
  60885. * **Encoder**
  60886. *
  60887. * The encoder is not currently implemented.
  60888. *
  60889. * **Decoder**
  60890. *
  60891. * 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.
  60892. *
  60893. * To update the configuration, use the following code:
  60894. * ```javascript
  60895. * DracoCompression.Configuration = {
  60896. * decoder: {
  60897. * wasmUrl: "<url to the WebAssembly library>",
  60898. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60899. * fallbackUrl: "<url to the fallback JavaScript library>",
  60900. * }
  60901. * };
  60902. * ```
  60903. *
  60904. * 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.
  60905. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60906. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60907. *
  60908. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60909. * ```javascript
  60910. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60911. * ```
  60912. *
  60913. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60914. */
  60915. export class DracoCompression implements IDisposable {
  60916. private _workerPoolPromise?;
  60917. private _decoderModulePromise?;
  60918. /**
  60919. * The configuration. Defaults to the following urls:
  60920. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60921. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60922. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60923. */
  60924. static Configuration: IDracoCompressionConfiguration;
  60925. /**
  60926. * Returns true if the decoder configuration is available.
  60927. */
  60928. static get DecoderAvailable(): boolean;
  60929. /**
  60930. * Default number of workers to create when creating the draco compression object.
  60931. */
  60932. static DefaultNumWorkers: number;
  60933. private static GetDefaultNumWorkers;
  60934. private static _Default;
  60935. /**
  60936. * Default instance for the draco compression object.
  60937. */
  60938. static get Default(): DracoCompression;
  60939. /**
  60940. * Constructor
  60941. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60942. */
  60943. constructor(numWorkers?: number);
  60944. /**
  60945. * Stop all async operations and release resources.
  60946. */
  60947. dispose(): void;
  60948. /**
  60949. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60950. * @returns a promise that resolves when ready
  60951. */
  60952. whenReadyAsync(): Promise<void>;
  60953. /**
  60954. * Decode Draco compressed mesh data to vertex data.
  60955. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60956. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60957. * @returns A promise that resolves with the decoded vertex data
  60958. */
  60959. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60960. [kind: string]: number;
  60961. }): Promise<VertexData>;
  60962. }
  60963. }
  60964. declare module BABYLON {
  60965. /**
  60966. * Class for building Constructive Solid Geometry
  60967. */
  60968. export class CSG {
  60969. private polygons;
  60970. /**
  60971. * The world matrix
  60972. */
  60973. matrix: Matrix;
  60974. /**
  60975. * Stores the position
  60976. */
  60977. position: Vector3;
  60978. /**
  60979. * Stores the rotation
  60980. */
  60981. rotation: Vector3;
  60982. /**
  60983. * Stores the rotation quaternion
  60984. */
  60985. rotationQuaternion: Nullable<Quaternion>;
  60986. /**
  60987. * Stores the scaling vector
  60988. */
  60989. scaling: Vector3;
  60990. /**
  60991. * Convert the Mesh to CSG
  60992. * @param mesh The Mesh to convert to CSG
  60993. * @returns A new CSG from the Mesh
  60994. */
  60995. static FromMesh(mesh: Mesh): CSG;
  60996. /**
  60997. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60998. * @param polygons Polygons used to construct a CSG solid
  60999. */
  61000. private static FromPolygons;
  61001. /**
  61002. * Clones, or makes a deep copy, of the CSG
  61003. * @returns A new CSG
  61004. */
  61005. clone(): CSG;
  61006. /**
  61007. * Unions this CSG with another CSG
  61008. * @param csg The CSG to union against this CSG
  61009. * @returns The unioned CSG
  61010. */
  61011. union(csg: CSG): CSG;
  61012. /**
  61013. * Unions this CSG with another CSG in place
  61014. * @param csg The CSG to union against this CSG
  61015. */
  61016. unionInPlace(csg: CSG): void;
  61017. /**
  61018. * Subtracts this CSG with another CSG
  61019. * @param csg The CSG to subtract against this CSG
  61020. * @returns A new CSG
  61021. */
  61022. subtract(csg: CSG): CSG;
  61023. /**
  61024. * Subtracts this CSG with another CSG in place
  61025. * @param csg The CSG to subtact against this CSG
  61026. */
  61027. subtractInPlace(csg: CSG): void;
  61028. /**
  61029. * Intersect this CSG with another CSG
  61030. * @param csg The CSG to intersect against this CSG
  61031. * @returns A new CSG
  61032. */
  61033. intersect(csg: CSG): CSG;
  61034. /**
  61035. * Intersects this CSG with another CSG in place
  61036. * @param csg The CSG to intersect against this CSG
  61037. */
  61038. intersectInPlace(csg: CSG): void;
  61039. /**
  61040. * Return a new CSG solid with solid and empty space switched. This solid is
  61041. * not modified.
  61042. * @returns A new CSG solid with solid and empty space switched
  61043. */
  61044. inverse(): CSG;
  61045. /**
  61046. * Inverses the CSG in place
  61047. */
  61048. inverseInPlace(): void;
  61049. /**
  61050. * This is used to keep meshes transformations so they can be restored
  61051. * when we build back a Babylon Mesh
  61052. * NB : All CSG operations are performed in world coordinates
  61053. * @param csg The CSG to copy the transform attributes from
  61054. * @returns This CSG
  61055. */
  61056. copyTransformAttributes(csg: CSG): CSG;
  61057. /**
  61058. * Build Raw mesh from CSG
  61059. * Coordinates here are in world space
  61060. * @param name The name of the mesh geometry
  61061. * @param scene The Scene
  61062. * @param keepSubMeshes Specifies if the submeshes should be kept
  61063. * @returns A new Mesh
  61064. */
  61065. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61066. /**
  61067. * Build Mesh from CSG taking material and transforms into account
  61068. * @param name The name of the Mesh
  61069. * @param material The material of the Mesh
  61070. * @param scene The Scene
  61071. * @param keepSubMeshes Specifies if submeshes should be kept
  61072. * @returns The new Mesh
  61073. */
  61074. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61075. }
  61076. }
  61077. declare module BABYLON {
  61078. /**
  61079. * Class used to create a trail following a mesh
  61080. */
  61081. export class TrailMesh extends Mesh {
  61082. private _generator;
  61083. private _autoStart;
  61084. private _running;
  61085. private _diameter;
  61086. private _length;
  61087. private _sectionPolygonPointsCount;
  61088. private _sectionVectors;
  61089. private _sectionNormalVectors;
  61090. private _beforeRenderObserver;
  61091. /**
  61092. * @constructor
  61093. * @param name The value used by scene.getMeshByName() to do a lookup.
  61094. * @param generator The mesh or transform node to generate a trail.
  61095. * @param scene The scene to add this mesh to.
  61096. * @param diameter Diameter of trailing mesh. Default is 1.
  61097. * @param length Length of trailing mesh. Default is 60.
  61098. * @param autoStart Automatically start trailing mesh. Default true.
  61099. */
  61100. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61101. /**
  61102. * "TrailMesh"
  61103. * @returns "TrailMesh"
  61104. */
  61105. getClassName(): string;
  61106. private _createMesh;
  61107. /**
  61108. * Start trailing mesh.
  61109. */
  61110. start(): void;
  61111. /**
  61112. * Stop trailing mesh.
  61113. */
  61114. stop(): void;
  61115. /**
  61116. * Update trailing mesh geometry.
  61117. */
  61118. update(): void;
  61119. /**
  61120. * Returns a new TrailMesh object.
  61121. * @param name is a string, the name given to the new mesh
  61122. * @param newGenerator use new generator object for cloned trail mesh
  61123. * @returns a new mesh
  61124. */
  61125. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61126. /**
  61127. * Serializes this trail mesh
  61128. * @param serializationObject object to write serialization to
  61129. */
  61130. serialize(serializationObject: any): void;
  61131. /**
  61132. * Parses a serialized trail mesh
  61133. * @param parsedMesh the serialized mesh
  61134. * @param scene the scene to create the trail mesh in
  61135. * @returns the created trail mesh
  61136. */
  61137. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61138. }
  61139. }
  61140. declare module BABYLON {
  61141. /**
  61142. * Class containing static functions to help procedurally build meshes
  61143. */
  61144. export class TiledBoxBuilder {
  61145. /**
  61146. * Creates a box mesh
  61147. * 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)
  61148. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61150. * * 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
  61151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61152. * @param name defines the name of the mesh
  61153. * @param options defines the options used to create the mesh
  61154. * @param scene defines the hosting scene
  61155. * @returns the box mesh
  61156. */
  61157. static CreateTiledBox(name: string, options: {
  61158. pattern?: number;
  61159. width?: number;
  61160. height?: number;
  61161. depth?: number;
  61162. tileSize?: number;
  61163. tileWidth?: number;
  61164. tileHeight?: number;
  61165. alignHorizontal?: number;
  61166. alignVertical?: number;
  61167. faceUV?: Vector4[];
  61168. faceColors?: Color4[];
  61169. sideOrientation?: number;
  61170. updatable?: boolean;
  61171. }, scene?: Nullable<Scene>): Mesh;
  61172. }
  61173. }
  61174. declare module BABYLON {
  61175. /**
  61176. * Class containing static functions to help procedurally build meshes
  61177. */
  61178. export class TorusKnotBuilder {
  61179. /**
  61180. * Creates a torus knot mesh
  61181. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61182. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61183. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61184. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61186. * * 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
  61187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61188. * @param name defines the name of the mesh
  61189. * @param options defines the options used to create the mesh
  61190. * @param scene defines the hosting scene
  61191. * @returns the torus knot mesh
  61192. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61193. */
  61194. static CreateTorusKnot(name: string, options: {
  61195. radius?: number;
  61196. tube?: number;
  61197. radialSegments?: number;
  61198. tubularSegments?: number;
  61199. p?: number;
  61200. q?: number;
  61201. updatable?: boolean;
  61202. sideOrientation?: number;
  61203. frontUVs?: Vector4;
  61204. backUVs?: Vector4;
  61205. }, scene: any): Mesh;
  61206. }
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * Polygon
  61211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61212. */
  61213. export class Polygon {
  61214. /**
  61215. * Creates a rectangle
  61216. * @param xmin bottom X coord
  61217. * @param ymin bottom Y coord
  61218. * @param xmax top X coord
  61219. * @param ymax top Y coord
  61220. * @returns points that make the resulting rectation
  61221. */
  61222. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61223. /**
  61224. * Creates a circle
  61225. * @param radius radius of circle
  61226. * @param cx scale in x
  61227. * @param cy scale in y
  61228. * @param numberOfSides number of sides that make up the circle
  61229. * @returns points that make the resulting circle
  61230. */
  61231. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61232. /**
  61233. * Creates a polygon from input string
  61234. * @param input Input polygon data
  61235. * @returns the parsed points
  61236. */
  61237. static Parse(input: string): Vector2[];
  61238. /**
  61239. * Starts building a polygon from x and y coordinates
  61240. * @param x x coordinate
  61241. * @param y y coordinate
  61242. * @returns the started path2
  61243. */
  61244. static StartingAt(x: number, y: number): Path2;
  61245. }
  61246. /**
  61247. * Builds a polygon
  61248. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61249. */
  61250. export class PolygonMeshBuilder {
  61251. private _points;
  61252. private _outlinepoints;
  61253. private _holes;
  61254. private _name;
  61255. private _scene;
  61256. private _epoints;
  61257. private _eholes;
  61258. private _addToepoint;
  61259. /**
  61260. * Babylon reference to the earcut plugin.
  61261. */
  61262. bjsEarcut: any;
  61263. /**
  61264. * Creates a PolygonMeshBuilder
  61265. * @param name name of the builder
  61266. * @param contours Path of the polygon
  61267. * @param scene scene to add to when creating the mesh
  61268. * @param earcutInjection can be used to inject your own earcut reference
  61269. */
  61270. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61271. /**
  61272. * Adds a whole within the polygon
  61273. * @param hole Array of points defining the hole
  61274. * @returns this
  61275. */
  61276. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61277. /**
  61278. * Creates the polygon
  61279. * @param updatable If the mesh should be updatable
  61280. * @param depth The depth of the mesh created
  61281. * @returns the created mesh
  61282. */
  61283. build(updatable?: boolean, depth?: number): Mesh;
  61284. /**
  61285. * Creates the polygon
  61286. * @param depth The depth of the mesh created
  61287. * @returns the created VertexData
  61288. */
  61289. buildVertexData(depth?: number): VertexData;
  61290. /**
  61291. * Adds a side to the polygon
  61292. * @param positions points that make the polygon
  61293. * @param normals normals of the polygon
  61294. * @param uvs uvs of the polygon
  61295. * @param indices indices of the polygon
  61296. * @param bounds bounds of the polygon
  61297. * @param points points of the polygon
  61298. * @param depth depth of the polygon
  61299. * @param flip flip of the polygon
  61300. */
  61301. private addSide;
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. /**
  61306. * Class containing static functions to help procedurally build meshes
  61307. */
  61308. export class PolygonBuilder {
  61309. /**
  61310. * Creates a polygon mesh
  61311. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61312. * * 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
  61313. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61315. * * 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)
  61316. * * Remember you can only change the shape positions, not their number when updating a polygon
  61317. * @param name defines the name of the mesh
  61318. * @param options defines the options used to create the mesh
  61319. * @param scene defines the hosting scene
  61320. * @param earcutInjection can be used to inject your own earcut reference
  61321. * @returns the polygon mesh
  61322. */
  61323. static CreatePolygon(name: string, options: {
  61324. shape: Vector3[];
  61325. holes?: Vector3[][];
  61326. depth?: number;
  61327. faceUV?: Vector4[];
  61328. faceColors?: Color4[];
  61329. updatable?: boolean;
  61330. sideOrientation?: number;
  61331. frontUVs?: Vector4;
  61332. backUVs?: Vector4;
  61333. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61334. /**
  61335. * Creates an extruded polygon mesh, with depth in the Y direction.
  61336. * * 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)
  61337. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61338. * @param name defines the name of the mesh
  61339. * @param options defines the options used to create the mesh
  61340. * @param scene defines the hosting scene
  61341. * @param earcutInjection can be used to inject your own earcut reference
  61342. * @returns the polygon mesh
  61343. */
  61344. static ExtrudePolygon(name: string, options: {
  61345. shape: Vector3[];
  61346. holes?: Vector3[][];
  61347. depth?: number;
  61348. faceUV?: Vector4[];
  61349. faceColors?: Color4[];
  61350. updatable?: boolean;
  61351. sideOrientation?: number;
  61352. frontUVs?: Vector4;
  61353. backUVs?: Vector4;
  61354. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61355. }
  61356. }
  61357. declare module BABYLON {
  61358. /**
  61359. * Class containing static functions to help procedurally build meshes
  61360. */
  61361. export class LatheBuilder {
  61362. /**
  61363. * Creates lathe mesh.
  61364. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61365. * * 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
  61366. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61367. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61368. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61369. * * 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
  61370. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61371. * * 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
  61372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61373. * * 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
  61374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61376. * @param name defines the name of the mesh
  61377. * @param options defines the options used to create the mesh
  61378. * @param scene defines the hosting scene
  61379. * @returns the lathe mesh
  61380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61381. */
  61382. static CreateLathe(name: string, options: {
  61383. shape: Vector3[];
  61384. radius?: number;
  61385. tessellation?: number;
  61386. clip?: number;
  61387. arc?: number;
  61388. closed?: boolean;
  61389. updatable?: boolean;
  61390. sideOrientation?: number;
  61391. frontUVs?: Vector4;
  61392. backUVs?: Vector4;
  61393. cap?: number;
  61394. invertUV?: boolean;
  61395. }, scene?: Nullable<Scene>): Mesh;
  61396. }
  61397. }
  61398. declare module BABYLON {
  61399. /**
  61400. * Class containing static functions to help procedurally build meshes
  61401. */
  61402. export class TiledPlaneBuilder {
  61403. /**
  61404. * Creates a tiled plane mesh
  61405. * * The parameter `pattern` will, depending on value, do nothing or
  61406. * * * flip (reflect about central vertical) alternate tiles across and up
  61407. * * * flip every tile on alternate rows
  61408. * * * rotate (180 degs) alternate tiles across and up
  61409. * * * rotate every tile on alternate rows
  61410. * * * flip and rotate alternate tiles across and up
  61411. * * * flip and rotate every tile on alternate rows
  61412. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61413. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61414. * * 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
  61415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61416. * * 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)
  61417. * * 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)
  61418. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61419. * @param name defines the name of the mesh
  61420. * @param options defines the options used to create the mesh
  61421. * @param scene defines the hosting scene
  61422. * @returns the box mesh
  61423. */
  61424. static CreateTiledPlane(name: string, options: {
  61425. pattern?: number;
  61426. tileSize?: number;
  61427. tileWidth?: number;
  61428. tileHeight?: number;
  61429. size?: number;
  61430. width?: number;
  61431. height?: number;
  61432. alignHorizontal?: number;
  61433. alignVertical?: number;
  61434. sideOrientation?: number;
  61435. frontUVs?: Vector4;
  61436. backUVs?: Vector4;
  61437. updatable?: boolean;
  61438. }, scene?: Nullable<Scene>): Mesh;
  61439. }
  61440. }
  61441. declare module BABYLON {
  61442. /**
  61443. * Class containing static functions to help procedurally build meshes
  61444. */
  61445. export class TubeBuilder {
  61446. /**
  61447. * Creates a tube mesh.
  61448. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61449. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61450. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61451. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61452. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61453. * * 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)
  61454. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61455. * * 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
  61456. * * 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
  61457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61458. * * 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
  61459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61461. * @param name defines the name of the mesh
  61462. * @param options defines the options used to create the mesh
  61463. * @param scene defines the hosting scene
  61464. * @returns the tube mesh
  61465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61466. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61467. */
  61468. static CreateTube(name: string, options: {
  61469. path: Vector3[];
  61470. radius?: number;
  61471. tessellation?: number;
  61472. radiusFunction?: {
  61473. (i: number, distance: number): number;
  61474. };
  61475. cap?: number;
  61476. arc?: number;
  61477. updatable?: boolean;
  61478. sideOrientation?: number;
  61479. frontUVs?: Vector4;
  61480. backUVs?: Vector4;
  61481. instance?: Mesh;
  61482. invertUV?: boolean;
  61483. }, scene?: Nullable<Scene>): Mesh;
  61484. }
  61485. }
  61486. declare module BABYLON {
  61487. /**
  61488. * Class containing static functions to help procedurally build meshes
  61489. */
  61490. export class IcoSphereBuilder {
  61491. /**
  61492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61494. * * 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`)
  61495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61496. * * 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
  61497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61498. * * 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
  61499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61500. * @param name defines the name of the mesh
  61501. * @param options defines the options used to create the mesh
  61502. * @param scene defines the hosting scene
  61503. * @returns the icosahedron mesh
  61504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61505. */
  61506. static CreateIcoSphere(name: string, options: {
  61507. radius?: number;
  61508. radiusX?: number;
  61509. radiusY?: number;
  61510. radiusZ?: number;
  61511. flat?: boolean;
  61512. subdivisions?: number;
  61513. sideOrientation?: number;
  61514. frontUVs?: Vector4;
  61515. backUVs?: Vector4;
  61516. updatable?: boolean;
  61517. }, scene?: Nullable<Scene>): Mesh;
  61518. }
  61519. }
  61520. declare module BABYLON {
  61521. /**
  61522. * Class containing static functions to help procedurally build meshes
  61523. */
  61524. export class DecalBuilder {
  61525. /**
  61526. * Creates a decal mesh.
  61527. * 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
  61528. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61529. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61530. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61531. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61532. * @param name defines the name of the mesh
  61533. * @param sourceMesh defines the mesh where the decal must be applied
  61534. * @param options defines the options used to create the mesh
  61535. * @param scene defines the hosting scene
  61536. * @returns the decal mesh
  61537. * @see https://doc.babylonjs.com/how_to/decals
  61538. */
  61539. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61540. position?: Vector3;
  61541. normal?: Vector3;
  61542. size?: Vector3;
  61543. angle?: number;
  61544. }): Mesh;
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /**
  61549. * Class containing static functions to help procedurally build meshes
  61550. */
  61551. export class MeshBuilder {
  61552. /**
  61553. * Creates a box mesh
  61554. * * The parameter `size` sets the size (float) of each box side (default 1)
  61555. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61556. * * 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)
  61557. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61559. * * 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
  61560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61561. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61562. * @param name defines the name of the mesh
  61563. * @param options defines the options used to create the mesh
  61564. * @param scene defines the hosting scene
  61565. * @returns the box mesh
  61566. */
  61567. static CreateBox(name: string, options: {
  61568. size?: number;
  61569. width?: number;
  61570. height?: number;
  61571. depth?: number;
  61572. faceUV?: Vector4[];
  61573. faceColors?: Color4[];
  61574. sideOrientation?: number;
  61575. frontUVs?: Vector4;
  61576. backUVs?: Vector4;
  61577. wrap?: boolean;
  61578. topBaseAt?: number;
  61579. bottomBaseAt?: number;
  61580. updatable?: boolean;
  61581. }, scene?: Nullable<Scene>): Mesh;
  61582. /**
  61583. * Creates a tiled box mesh
  61584. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61586. * @param name defines the name of the mesh
  61587. * @param options defines the options used to create the mesh
  61588. * @param scene defines the hosting scene
  61589. * @returns the tiled box mesh
  61590. */
  61591. static CreateTiledBox(name: string, options: {
  61592. pattern?: number;
  61593. size?: number;
  61594. width?: number;
  61595. height?: number;
  61596. depth: number;
  61597. tileSize?: number;
  61598. tileWidth?: number;
  61599. tileHeight?: number;
  61600. faceUV?: Vector4[];
  61601. faceColors?: Color4[];
  61602. alignHorizontal?: number;
  61603. alignVertical?: number;
  61604. sideOrientation?: number;
  61605. updatable?: boolean;
  61606. }, scene?: Nullable<Scene>): Mesh;
  61607. /**
  61608. * Creates a sphere mesh
  61609. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61610. * * 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`)
  61611. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61612. * * 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
  61613. * * 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)
  61614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61615. * * 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
  61616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61617. * @param name defines the name of the mesh
  61618. * @param options defines the options used to create the mesh
  61619. * @param scene defines the hosting scene
  61620. * @returns the sphere mesh
  61621. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61622. */
  61623. static CreateSphere(name: string, options: {
  61624. segments?: number;
  61625. diameter?: number;
  61626. diameterX?: number;
  61627. diameterY?: number;
  61628. diameterZ?: number;
  61629. arc?: number;
  61630. slice?: number;
  61631. sideOrientation?: number;
  61632. frontUVs?: Vector4;
  61633. backUVs?: Vector4;
  61634. updatable?: boolean;
  61635. }, scene?: Nullable<Scene>): Mesh;
  61636. /**
  61637. * Creates a plane polygonal mesh. By default, this is a disc
  61638. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61639. * * 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
  61640. * * 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
  61641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61642. * * 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
  61643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61644. * @param name defines the name of the mesh
  61645. * @param options defines the options used to create the mesh
  61646. * @param scene defines the hosting scene
  61647. * @returns the plane polygonal mesh
  61648. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61649. */
  61650. static CreateDisc(name: string, options: {
  61651. radius?: number;
  61652. tessellation?: number;
  61653. arc?: number;
  61654. updatable?: boolean;
  61655. sideOrientation?: number;
  61656. frontUVs?: Vector4;
  61657. backUVs?: Vector4;
  61658. }, scene?: Nullable<Scene>): Mesh;
  61659. /**
  61660. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61661. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61662. * * 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`)
  61663. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61664. * * 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
  61665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61666. * * 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
  61667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61668. * @param name defines the name of the mesh
  61669. * @param options defines the options used to create the mesh
  61670. * @param scene defines the hosting scene
  61671. * @returns the icosahedron mesh
  61672. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61673. */
  61674. static CreateIcoSphere(name: string, options: {
  61675. radius?: number;
  61676. radiusX?: number;
  61677. radiusY?: number;
  61678. radiusZ?: number;
  61679. flat?: boolean;
  61680. subdivisions?: number;
  61681. sideOrientation?: number;
  61682. frontUVs?: Vector4;
  61683. backUVs?: Vector4;
  61684. updatable?: boolean;
  61685. }, scene?: Nullable<Scene>): Mesh;
  61686. /**
  61687. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61688. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61689. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61690. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61691. * * 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
  61692. * * 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
  61693. * * 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
  61694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61695. * * 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
  61696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61697. * * 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
  61698. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61699. * * 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
  61700. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61702. * @param name defines the name of the mesh
  61703. * @param options defines the options used to create the mesh
  61704. * @param scene defines the hosting scene
  61705. * @returns the ribbon mesh
  61706. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61708. */
  61709. static CreateRibbon(name: string, options: {
  61710. pathArray: Vector3[][];
  61711. closeArray?: boolean;
  61712. closePath?: boolean;
  61713. offset?: number;
  61714. updatable?: boolean;
  61715. sideOrientation?: number;
  61716. frontUVs?: Vector4;
  61717. backUVs?: Vector4;
  61718. instance?: Mesh;
  61719. invertUV?: boolean;
  61720. uvs?: Vector2[];
  61721. colors?: Color4[];
  61722. }, scene?: Nullable<Scene>): Mesh;
  61723. /**
  61724. * Creates a cylinder or a cone mesh
  61725. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61726. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61727. * * 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.
  61728. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61729. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61730. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61731. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61732. * * 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).
  61733. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61734. * * 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).
  61735. * * 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
  61736. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61737. * * 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
  61738. * * 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.
  61739. * * If `enclose` is false, a ring surface is one element.
  61740. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61741. * * 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
  61742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61743. * * 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
  61744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61745. * @param name defines the name of the mesh
  61746. * @param options defines the options used to create the mesh
  61747. * @param scene defines the hosting scene
  61748. * @returns the cylinder mesh
  61749. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61750. */
  61751. static CreateCylinder(name: string, options: {
  61752. height?: number;
  61753. diameterTop?: number;
  61754. diameterBottom?: number;
  61755. diameter?: number;
  61756. tessellation?: number;
  61757. subdivisions?: number;
  61758. arc?: number;
  61759. faceColors?: Color4[];
  61760. faceUV?: Vector4[];
  61761. updatable?: boolean;
  61762. hasRings?: boolean;
  61763. enclose?: boolean;
  61764. cap?: number;
  61765. sideOrientation?: number;
  61766. frontUVs?: Vector4;
  61767. backUVs?: Vector4;
  61768. }, scene?: Nullable<Scene>): Mesh;
  61769. /**
  61770. * Creates a torus mesh
  61771. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61772. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61773. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61775. * * 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
  61776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61777. * @param name defines the name of the mesh
  61778. * @param options defines the options used to create the mesh
  61779. * @param scene defines the hosting scene
  61780. * @returns the torus mesh
  61781. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61782. */
  61783. static CreateTorus(name: string, options: {
  61784. diameter?: number;
  61785. thickness?: number;
  61786. tessellation?: number;
  61787. updatable?: boolean;
  61788. sideOrientation?: number;
  61789. frontUVs?: Vector4;
  61790. backUVs?: Vector4;
  61791. }, scene?: Nullable<Scene>): Mesh;
  61792. /**
  61793. * Creates a torus knot mesh
  61794. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61795. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61796. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61797. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61799. * * 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
  61800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61801. * @param name defines the name of the mesh
  61802. * @param options defines the options used to create the mesh
  61803. * @param scene defines the hosting scene
  61804. * @returns the torus knot mesh
  61805. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61806. */
  61807. static CreateTorusKnot(name: string, options: {
  61808. radius?: number;
  61809. tube?: number;
  61810. radialSegments?: number;
  61811. tubularSegments?: number;
  61812. p?: number;
  61813. q?: number;
  61814. updatable?: boolean;
  61815. sideOrientation?: number;
  61816. frontUVs?: Vector4;
  61817. backUVs?: Vector4;
  61818. }, scene?: Nullable<Scene>): Mesh;
  61819. /**
  61820. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61821. * * 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
  61822. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61823. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61824. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61825. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61826. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61827. * * 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
  61828. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61831. * @param name defines the name of the new line system
  61832. * @param options defines the options used to create the line system
  61833. * @param scene defines the hosting scene
  61834. * @returns a new line system mesh
  61835. */
  61836. static CreateLineSystem(name: string, options: {
  61837. lines: Vector3[][];
  61838. updatable?: boolean;
  61839. instance?: Nullable<LinesMesh>;
  61840. colors?: Nullable<Color4[][]>;
  61841. useVertexAlpha?: boolean;
  61842. }, scene: Nullable<Scene>): LinesMesh;
  61843. /**
  61844. * Creates a line mesh
  61845. * 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
  61846. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61847. * * The parameter `points` is an array successive Vector3
  61848. * * 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
  61849. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61850. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61851. * * When updating an instance, remember that only point positions can change, not the number of points
  61852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61854. * @param name defines the name of the new line system
  61855. * @param options defines the options used to create the line system
  61856. * @param scene defines the hosting scene
  61857. * @returns a new line mesh
  61858. */
  61859. static CreateLines(name: string, options: {
  61860. points: Vector3[];
  61861. updatable?: boolean;
  61862. instance?: Nullable<LinesMesh>;
  61863. colors?: Color4[];
  61864. useVertexAlpha?: boolean;
  61865. }, scene?: Nullable<Scene>): LinesMesh;
  61866. /**
  61867. * Creates a dashed line mesh
  61868. * * 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
  61869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61870. * * The parameter `points` is an array successive Vector3
  61871. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61872. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61873. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61874. * * 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
  61875. * * When updating an instance, remember that only point positions can change, not the number of points
  61876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61877. * @param name defines the name of the mesh
  61878. * @param options defines the options used to create the mesh
  61879. * @param scene defines the hosting scene
  61880. * @returns the dashed line mesh
  61881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61882. */
  61883. static CreateDashedLines(name: string, options: {
  61884. points: Vector3[];
  61885. dashSize?: number;
  61886. gapSize?: number;
  61887. dashNb?: number;
  61888. updatable?: boolean;
  61889. instance?: LinesMesh;
  61890. }, scene?: Nullable<Scene>): LinesMesh;
  61891. /**
  61892. * 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.
  61893. * * 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.
  61894. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61895. * * 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.
  61896. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61897. * * 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
  61898. * * 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
  61899. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61901. * * 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
  61902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61904. * @param name defines the name of the mesh
  61905. * @param options defines the options used to create the mesh
  61906. * @param scene defines the hosting scene
  61907. * @returns the extruded shape mesh
  61908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61910. */
  61911. static ExtrudeShape(name: string, options: {
  61912. shape: Vector3[];
  61913. path: Vector3[];
  61914. scale?: number;
  61915. rotation?: number;
  61916. cap?: number;
  61917. updatable?: boolean;
  61918. sideOrientation?: number;
  61919. frontUVs?: Vector4;
  61920. backUVs?: Vector4;
  61921. instance?: Mesh;
  61922. invertUV?: boolean;
  61923. }, scene?: Nullable<Scene>): Mesh;
  61924. /**
  61925. * Creates an custom extruded shape mesh.
  61926. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61927. * * 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.
  61928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61929. * * 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
  61930. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61931. * * 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
  61932. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61933. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61934. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61935. * * 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
  61936. * * 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
  61937. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61939. * * 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
  61940. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61942. * @param name defines the name of the mesh
  61943. * @param options defines the options used to create the mesh
  61944. * @param scene defines the hosting scene
  61945. * @returns the custom extruded shape mesh
  61946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61949. */
  61950. static ExtrudeShapeCustom(name: string, options: {
  61951. shape: Vector3[];
  61952. path: Vector3[];
  61953. scaleFunction?: any;
  61954. rotationFunction?: any;
  61955. ribbonCloseArray?: boolean;
  61956. ribbonClosePath?: boolean;
  61957. cap?: number;
  61958. updatable?: boolean;
  61959. sideOrientation?: number;
  61960. frontUVs?: Vector4;
  61961. backUVs?: Vector4;
  61962. instance?: Mesh;
  61963. invertUV?: boolean;
  61964. }, scene?: Nullable<Scene>): Mesh;
  61965. /**
  61966. * Creates lathe mesh.
  61967. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61968. * * 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
  61969. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61970. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61971. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61972. * * 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
  61973. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61974. * * 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
  61975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61976. * * 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
  61977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61979. * @param name defines the name of the mesh
  61980. * @param options defines the options used to create the mesh
  61981. * @param scene defines the hosting scene
  61982. * @returns the lathe mesh
  61983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61984. */
  61985. static CreateLathe(name: string, options: {
  61986. shape: Vector3[];
  61987. radius?: number;
  61988. tessellation?: number;
  61989. clip?: number;
  61990. arc?: number;
  61991. closed?: boolean;
  61992. updatable?: boolean;
  61993. sideOrientation?: number;
  61994. frontUVs?: Vector4;
  61995. backUVs?: Vector4;
  61996. cap?: number;
  61997. invertUV?: boolean;
  61998. }, scene?: Nullable<Scene>): Mesh;
  61999. /**
  62000. * Creates a tiled plane mesh
  62001. * * You can set a limited pattern arrangement with the tiles
  62002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62003. * * 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
  62004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62005. * @param name defines the name of the mesh
  62006. * @param options defines the options used to create the mesh
  62007. * @param scene defines the hosting scene
  62008. * @returns the plane mesh
  62009. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62010. */
  62011. static CreateTiledPlane(name: string, options: {
  62012. pattern?: number;
  62013. tileSize?: number;
  62014. tileWidth?: number;
  62015. tileHeight?: number;
  62016. size?: number;
  62017. width?: number;
  62018. height?: number;
  62019. alignHorizontal?: number;
  62020. alignVertical?: number;
  62021. sideOrientation?: number;
  62022. frontUVs?: Vector4;
  62023. backUVs?: Vector4;
  62024. updatable?: boolean;
  62025. }, scene?: Nullable<Scene>): Mesh;
  62026. /**
  62027. * Creates a plane mesh
  62028. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62029. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62030. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62032. * * 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
  62033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62034. * @param name defines the name of the mesh
  62035. * @param options defines the options used to create the mesh
  62036. * @param scene defines the hosting scene
  62037. * @returns the plane mesh
  62038. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62039. */
  62040. static CreatePlane(name: string, options: {
  62041. size?: number;
  62042. width?: number;
  62043. height?: number;
  62044. sideOrientation?: number;
  62045. frontUVs?: Vector4;
  62046. backUVs?: Vector4;
  62047. updatable?: boolean;
  62048. sourcePlane?: Plane;
  62049. }, scene?: Nullable<Scene>): Mesh;
  62050. /**
  62051. * Creates a ground mesh
  62052. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62053. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62055. * @param name defines the name of the mesh
  62056. * @param options defines the options used to create the mesh
  62057. * @param scene defines the hosting scene
  62058. * @returns the ground mesh
  62059. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62060. */
  62061. static CreateGround(name: string, options: {
  62062. width?: number;
  62063. height?: number;
  62064. subdivisions?: number;
  62065. subdivisionsX?: number;
  62066. subdivisionsY?: number;
  62067. updatable?: boolean;
  62068. }, scene?: Nullable<Scene>): Mesh;
  62069. /**
  62070. * Creates a tiled ground mesh
  62071. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62072. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62073. * * 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
  62074. * * 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
  62075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62076. * @param name defines the name of the mesh
  62077. * @param options defines the options used to create the mesh
  62078. * @param scene defines the hosting scene
  62079. * @returns the tiled ground mesh
  62080. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62081. */
  62082. static CreateTiledGround(name: string, options: {
  62083. xmin: number;
  62084. zmin: number;
  62085. xmax: number;
  62086. zmax: number;
  62087. subdivisions?: {
  62088. w: number;
  62089. h: number;
  62090. };
  62091. precision?: {
  62092. w: number;
  62093. h: number;
  62094. };
  62095. updatable?: boolean;
  62096. }, scene?: Nullable<Scene>): Mesh;
  62097. /**
  62098. * Creates a ground mesh from a height map
  62099. * * The parameter `url` sets the URL of the height map image resource.
  62100. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62101. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62102. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62103. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62104. * * 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.
  62105. * * 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).
  62106. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62108. * @param name defines the name of the mesh
  62109. * @param url defines the url to the height map
  62110. * @param options defines the options used to create the mesh
  62111. * @param scene defines the hosting scene
  62112. * @returns the ground mesh
  62113. * @see https://doc.babylonjs.com/babylon101/height_map
  62114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62115. */
  62116. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62117. width?: number;
  62118. height?: number;
  62119. subdivisions?: number;
  62120. minHeight?: number;
  62121. maxHeight?: number;
  62122. colorFilter?: Color3;
  62123. alphaFilter?: number;
  62124. updatable?: boolean;
  62125. onReady?: (mesh: GroundMesh) => void;
  62126. }, scene?: Nullable<Scene>): GroundMesh;
  62127. /**
  62128. * Creates a polygon mesh
  62129. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62130. * * 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
  62131. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62133. * * 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)
  62134. * * Remember you can only change the shape positions, not their number when updating a polygon
  62135. * @param name defines the name of the mesh
  62136. * @param options defines the options used to create the mesh
  62137. * @param scene defines the hosting scene
  62138. * @param earcutInjection can be used to inject your own earcut reference
  62139. * @returns the polygon mesh
  62140. */
  62141. static CreatePolygon(name: string, options: {
  62142. shape: Vector3[];
  62143. holes?: Vector3[][];
  62144. depth?: number;
  62145. faceUV?: Vector4[];
  62146. faceColors?: Color4[];
  62147. updatable?: boolean;
  62148. sideOrientation?: number;
  62149. frontUVs?: Vector4;
  62150. backUVs?: Vector4;
  62151. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62152. /**
  62153. * Creates an extruded polygon mesh, with depth in the Y direction.
  62154. * * 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)
  62155. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62156. * @param name defines the name of the mesh
  62157. * @param options defines the options used to create the mesh
  62158. * @param scene defines the hosting scene
  62159. * @param earcutInjection can be used to inject your own earcut reference
  62160. * @returns the polygon mesh
  62161. */
  62162. static ExtrudePolygon(name: string, options: {
  62163. shape: Vector3[];
  62164. holes?: Vector3[][];
  62165. depth?: number;
  62166. faceUV?: Vector4[];
  62167. faceColors?: Color4[];
  62168. updatable?: boolean;
  62169. sideOrientation?: number;
  62170. frontUVs?: Vector4;
  62171. backUVs?: Vector4;
  62172. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62173. /**
  62174. * Creates a tube mesh.
  62175. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62176. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62177. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62178. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62179. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62180. * * 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)
  62181. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62182. * * 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
  62183. * * 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
  62184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62185. * * 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
  62186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62188. * @param name defines the name of the mesh
  62189. * @param options defines the options used to create the mesh
  62190. * @param scene defines the hosting scene
  62191. * @returns the tube mesh
  62192. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62193. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62194. */
  62195. static CreateTube(name: string, options: {
  62196. path: Vector3[];
  62197. radius?: number;
  62198. tessellation?: number;
  62199. radiusFunction?: {
  62200. (i: number, distance: number): number;
  62201. };
  62202. cap?: number;
  62203. arc?: number;
  62204. updatable?: boolean;
  62205. sideOrientation?: number;
  62206. frontUVs?: Vector4;
  62207. backUVs?: Vector4;
  62208. instance?: Mesh;
  62209. invertUV?: boolean;
  62210. }, scene?: Nullable<Scene>): Mesh;
  62211. /**
  62212. * Creates a polyhedron mesh
  62213. * * 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
  62214. * * The parameter `size` (positive float, default 1) sets the polygon size
  62215. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62216. * * 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`
  62217. * * 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
  62218. * * 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)`)
  62219. * * 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
  62220. * * 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
  62221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62222. * * 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
  62223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62224. * @param name defines the name of the mesh
  62225. * @param options defines the options used to create the mesh
  62226. * @param scene defines the hosting scene
  62227. * @returns the polyhedron mesh
  62228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62229. */
  62230. static CreatePolyhedron(name: string, options: {
  62231. type?: number;
  62232. size?: number;
  62233. sizeX?: number;
  62234. sizeY?: number;
  62235. sizeZ?: number;
  62236. custom?: any;
  62237. faceUV?: Vector4[];
  62238. faceColors?: Color4[];
  62239. flat?: boolean;
  62240. updatable?: boolean;
  62241. sideOrientation?: number;
  62242. frontUVs?: Vector4;
  62243. backUVs?: Vector4;
  62244. }, scene?: Nullable<Scene>): Mesh;
  62245. /**
  62246. * Creates a decal mesh.
  62247. * 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
  62248. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62249. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62250. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62251. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62252. * @param name defines the name of the mesh
  62253. * @param sourceMesh defines the mesh where the decal must be applied
  62254. * @param options defines the options used to create the mesh
  62255. * @param scene defines the hosting scene
  62256. * @returns the decal mesh
  62257. * @see https://doc.babylonjs.com/how_to/decals
  62258. */
  62259. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62260. position?: Vector3;
  62261. normal?: Vector3;
  62262. size?: Vector3;
  62263. angle?: number;
  62264. }): Mesh;
  62265. }
  62266. }
  62267. declare module BABYLON {
  62268. /**
  62269. * A simplifier interface for future simplification implementations
  62270. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62271. */
  62272. export interface ISimplifier {
  62273. /**
  62274. * Simplification of a given mesh according to the given settings.
  62275. * Since this requires computation, it is assumed that the function runs async.
  62276. * @param settings The settings of the simplification, including quality and distance
  62277. * @param successCallback A callback that will be called after the mesh was simplified.
  62278. * @param errorCallback in case of an error, this callback will be called. optional.
  62279. */
  62280. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62281. }
  62282. /**
  62283. * Expected simplification settings.
  62284. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62285. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62286. */
  62287. export interface ISimplificationSettings {
  62288. /**
  62289. * Gets or sets the expected quality
  62290. */
  62291. quality: number;
  62292. /**
  62293. * Gets or sets the distance when this optimized version should be used
  62294. */
  62295. distance: number;
  62296. /**
  62297. * Gets an already optimized mesh
  62298. */
  62299. optimizeMesh?: boolean;
  62300. }
  62301. /**
  62302. * Class used to specify simplification options
  62303. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62304. */
  62305. export class SimplificationSettings implements ISimplificationSettings {
  62306. /** expected quality */
  62307. quality: number;
  62308. /** distance when this optimized version should be used */
  62309. distance: number;
  62310. /** already optimized mesh */
  62311. optimizeMesh?: boolean | undefined;
  62312. /**
  62313. * Creates a SimplificationSettings
  62314. * @param quality expected quality
  62315. * @param distance distance when this optimized version should be used
  62316. * @param optimizeMesh already optimized mesh
  62317. */
  62318. constructor(
  62319. /** expected quality */
  62320. quality: number,
  62321. /** distance when this optimized version should be used */
  62322. distance: number,
  62323. /** already optimized mesh */
  62324. optimizeMesh?: boolean | undefined);
  62325. }
  62326. /**
  62327. * Interface used to define a simplification task
  62328. */
  62329. export interface ISimplificationTask {
  62330. /**
  62331. * Array of settings
  62332. */
  62333. settings: Array<ISimplificationSettings>;
  62334. /**
  62335. * Simplification type
  62336. */
  62337. simplificationType: SimplificationType;
  62338. /**
  62339. * Mesh to simplify
  62340. */
  62341. mesh: Mesh;
  62342. /**
  62343. * Callback called on success
  62344. */
  62345. successCallback?: () => void;
  62346. /**
  62347. * Defines if parallel processing can be used
  62348. */
  62349. parallelProcessing: boolean;
  62350. }
  62351. /**
  62352. * Queue used to order the simplification tasks
  62353. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62354. */
  62355. export class SimplificationQueue {
  62356. private _simplificationArray;
  62357. /**
  62358. * Gets a boolean indicating that the process is still running
  62359. */
  62360. running: boolean;
  62361. /**
  62362. * Creates a new queue
  62363. */
  62364. constructor();
  62365. /**
  62366. * Adds a new simplification task
  62367. * @param task defines a task to add
  62368. */
  62369. addTask(task: ISimplificationTask): void;
  62370. /**
  62371. * Execute next task
  62372. */
  62373. executeNext(): void;
  62374. /**
  62375. * Execute a simplification task
  62376. * @param task defines the task to run
  62377. */
  62378. runSimplification(task: ISimplificationTask): void;
  62379. private getSimplifier;
  62380. }
  62381. /**
  62382. * The implemented types of simplification
  62383. * At the moment only Quadratic Error Decimation is implemented
  62384. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62385. */
  62386. export enum SimplificationType {
  62387. /** Quadratic error decimation */
  62388. QUADRATIC = 0
  62389. }
  62390. /**
  62391. * An implementation of the Quadratic Error simplification algorithm.
  62392. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62393. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62394. * @author RaananW
  62395. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62396. */
  62397. export class QuadraticErrorSimplification implements ISimplifier {
  62398. private _mesh;
  62399. private triangles;
  62400. private vertices;
  62401. private references;
  62402. private _reconstructedMesh;
  62403. /** Gets or sets the number pf sync interations */
  62404. syncIterations: number;
  62405. /** Gets or sets the aggressiveness of the simplifier */
  62406. aggressiveness: number;
  62407. /** Gets or sets the number of allowed iterations for decimation */
  62408. decimationIterations: number;
  62409. /** Gets or sets the espilon to use for bounding box computation */
  62410. boundingBoxEpsilon: number;
  62411. /**
  62412. * Creates a new QuadraticErrorSimplification
  62413. * @param _mesh defines the target mesh
  62414. */
  62415. constructor(_mesh: Mesh);
  62416. /**
  62417. * Simplification of a given mesh according to the given settings.
  62418. * Since this requires computation, it is assumed that the function runs async.
  62419. * @param settings The settings of the simplification, including quality and distance
  62420. * @param successCallback A callback that will be called after the mesh was simplified.
  62421. */
  62422. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62423. private runDecimation;
  62424. private initWithMesh;
  62425. private init;
  62426. private reconstructMesh;
  62427. private initDecimatedMesh;
  62428. private isFlipped;
  62429. private updateTriangles;
  62430. private identifyBorder;
  62431. private updateMesh;
  62432. private vertexError;
  62433. private calculateError;
  62434. }
  62435. }
  62436. declare module BABYLON {
  62437. interface Scene {
  62438. /** @hidden (Backing field) */
  62439. _simplificationQueue: SimplificationQueue;
  62440. /**
  62441. * Gets or sets the simplification queue attached to the scene
  62442. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62443. */
  62444. simplificationQueue: SimplificationQueue;
  62445. }
  62446. interface Mesh {
  62447. /**
  62448. * Simplify the mesh according to the given array of settings.
  62449. * Function will return immediately and will simplify async
  62450. * @param settings a collection of simplification settings
  62451. * @param parallelProcessing should all levels calculate parallel or one after the other
  62452. * @param simplificationType the type of simplification to run
  62453. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62454. * @returns the current mesh
  62455. */
  62456. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62457. }
  62458. /**
  62459. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62460. * created in a scene
  62461. */
  62462. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62463. /**
  62464. * The component name helpfull to identify the component in the list of scene components.
  62465. */
  62466. readonly name: string;
  62467. /**
  62468. * The scene the component belongs to.
  62469. */
  62470. scene: Scene;
  62471. /**
  62472. * Creates a new instance of the component for the given scene
  62473. * @param scene Defines the scene to register the component in
  62474. */
  62475. constructor(scene: Scene);
  62476. /**
  62477. * Registers the component in a given scene
  62478. */
  62479. register(): void;
  62480. /**
  62481. * Rebuilds the elements related to this component in case of
  62482. * context lost for instance.
  62483. */
  62484. rebuild(): void;
  62485. /**
  62486. * Disposes the component and the associated ressources
  62487. */
  62488. dispose(): void;
  62489. private _beforeCameraUpdate;
  62490. }
  62491. }
  62492. declare module BABYLON {
  62493. /**
  62494. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62495. */
  62496. export interface INavigationEnginePlugin {
  62497. /**
  62498. * plugin name
  62499. */
  62500. name: string;
  62501. /**
  62502. * Creates a navigation mesh
  62503. * @param meshes array of all the geometry used to compute the navigatio mesh
  62504. * @param parameters bunch of parameters used to filter geometry
  62505. */
  62506. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62507. /**
  62508. * Create a navigation mesh debug mesh
  62509. * @param scene is where the mesh will be added
  62510. * @returns debug display mesh
  62511. */
  62512. createDebugNavMesh(scene: Scene): Mesh;
  62513. /**
  62514. * Get a navigation mesh constrained position, closest to the parameter position
  62515. * @param position world position
  62516. * @returns the closest point to position constrained by the navigation mesh
  62517. */
  62518. getClosestPoint(position: Vector3): Vector3;
  62519. /**
  62520. * Get a navigation mesh constrained position, closest to the parameter position
  62521. * @param position world position
  62522. * @param result output the closest point to position constrained by the navigation mesh
  62523. */
  62524. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62525. /**
  62526. * Get a navigation mesh constrained position, within a particular radius
  62527. * @param position world position
  62528. * @param maxRadius the maximum distance to the constrained world position
  62529. * @returns the closest point to position constrained by the navigation mesh
  62530. */
  62531. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62532. /**
  62533. * Get a navigation mesh constrained position, within a particular radius
  62534. * @param position world position
  62535. * @param maxRadius the maximum distance to the constrained world position
  62536. * @param result output the closest point to position constrained by the navigation mesh
  62537. */
  62538. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62539. /**
  62540. * Compute the final position from a segment made of destination-position
  62541. * @param position world position
  62542. * @param destination world position
  62543. * @returns the resulting point along the navmesh
  62544. */
  62545. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62546. /**
  62547. * Compute the final position from a segment made of destination-position
  62548. * @param position world position
  62549. * @param destination world position
  62550. * @param result output the resulting point along the navmesh
  62551. */
  62552. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62553. /**
  62554. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62555. * @param start world position
  62556. * @param end world position
  62557. * @returns array containing world position composing the path
  62558. */
  62559. computePath(start: Vector3, end: Vector3): Vector3[];
  62560. /**
  62561. * If this plugin is supported
  62562. * @returns true if plugin is supported
  62563. */
  62564. isSupported(): boolean;
  62565. /**
  62566. * Create a new Crowd so you can add agents
  62567. * @param maxAgents the maximum agent count in the crowd
  62568. * @param maxAgentRadius the maximum radius an agent can have
  62569. * @param scene to attach the crowd to
  62570. * @returns the crowd you can add agents to
  62571. */
  62572. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62573. /**
  62574. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62575. * The queries will try to find a solution within those bounds
  62576. * default is (1,1,1)
  62577. * @param extent x,y,z value that define the extent around the queries point of reference
  62578. */
  62579. setDefaultQueryExtent(extent: Vector3): void;
  62580. /**
  62581. * Get the Bounding box extent specified by setDefaultQueryExtent
  62582. * @returns the box extent values
  62583. */
  62584. getDefaultQueryExtent(): Vector3;
  62585. /**
  62586. * build the navmesh from a previously saved state using getNavmeshData
  62587. * @param data the Uint8Array returned by getNavmeshData
  62588. */
  62589. buildFromNavmeshData(data: Uint8Array): void;
  62590. /**
  62591. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62592. * @returns data the Uint8Array that can be saved and reused
  62593. */
  62594. getNavmeshData(): Uint8Array;
  62595. /**
  62596. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62597. * @param result output the box extent values
  62598. */
  62599. getDefaultQueryExtentToRef(result: Vector3): void;
  62600. /**
  62601. * Release all resources
  62602. */
  62603. dispose(): void;
  62604. }
  62605. /**
  62606. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62607. */
  62608. export interface ICrowd {
  62609. /**
  62610. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62611. * You can attach anything to that node. The node position is updated in the scene update tick.
  62612. * @param pos world position that will be constrained by the navigation mesh
  62613. * @param parameters agent parameters
  62614. * @param transform hooked to the agent that will be update by the scene
  62615. * @returns agent index
  62616. */
  62617. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62618. /**
  62619. * Returns the agent position in world space
  62620. * @param index agent index returned by addAgent
  62621. * @returns world space position
  62622. */
  62623. getAgentPosition(index: number): Vector3;
  62624. /**
  62625. * Gets the agent position result in world space
  62626. * @param index agent index returned by addAgent
  62627. * @param result output world space position
  62628. */
  62629. getAgentPositionToRef(index: number, result: Vector3): void;
  62630. /**
  62631. * Gets the agent velocity in world space
  62632. * @param index agent index returned by addAgent
  62633. * @returns world space velocity
  62634. */
  62635. getAgentVelocity(index: number): Vector3;
  62636. /**
  62637. * Gets the agent velocity result in world space
  62638. * @param index agent index returned by addAgent
  62639. * @param result output world space velocity
  62640. */
  62641. getAgentVelocityToRef(index: number, result: Vector3): void;
  62642. /**
  62643. * remove a particular agent previously created
  62644. * @param index agent index returned by addAgent
  62645. */
  62646. removeAgent(index: number): void;
  62647. /**
  62648. * get the list of all agents attached to this crowd
  62649. * @returns list of agent indices
  62650. */
  62651. getAgents(): number[];
  62652. /**
  62653. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62654. * @param deltaTime in seconds
  62655. */
  62656. update(deltaTime: number): void;
  62657. /**
  62658. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62659. * @param index agent index returned by addAgent
  62660. * @param destination targeted world position
  62661. */
  62662. agentGoto(index: number, destination: Vector3): void;
  62663. /**
  62664. * Teleport the agent to a new position
  62665. * @param index agent index returned by addAgent
  62666. * @param destination targeted world position
  62667. */
  62668. agentTeleport(index: number, destination: Vector3): void;
  62669. /**
  62670. * Update agent parameters
  62671. * @param index agent index returned by addAgent
  62672. * @param parameters agent parameters
  62673. */
  62674. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62675. /**
  62676. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62677. * The queries will try to find a solution within those bounds
  62678. * default is (1,1,1)
  62679. * @param extent x,y,z value that define the extent around the queries point of reference
  62680. */
  62681. setDefaultQueryExtent(extent: Vector3): void;
  62682. /**
  62683. * Get the Bounding box extent specified by setDefaultQueryExtent
  62684. * @returns the box extent values
  62685. */
  62686. getDefaultQueryExtent(): Vector3;
  62687. /**
  62688. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62689. * @param result output the box extent values
  62690. */
  62691. getDefaultQueryExtentToRef(result: Vector3): void;
  62692. /**
  62693. * Release all resources
  62694. */
  62695. dispose(): void;
  62696. }
  62697. /**
  62698. * Configures an agent
  62699. */
  62700. export interface IAgentParameters {
  62701. /**
  62702. * Agent radius. [Limit: >= 0]
  62703. */
  62704. radius: number;
  62705. /**
  62706. * Agent height. [Limit: > 0]
  62707. */
  62708. height: number;
  62709. /**
  62710. * Maximum allowed acceleration. [Limit: >= 0]
  62711. */
  62712. maxAcceleration: number;
  62713. /**
  62714. * Maximum allowed speed. [Limit: >= 0]
  62715. */
  62716. maxSpeed: number;
  62717. /**
  62718. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62719. */
  62720. collisionQueryRange: number;
  62721. /**
  62722. * The path visibility optimization range. [Limit: > 0]
  62723. */
  62724. pathOptimizationRange: number;
  62725. /**
  62726. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62727. */
  62728. separationWeight: number;
  62729. }
  62730. /**
  62731. * Configures the navigation mesh creation
  62732. */
  62733. export interface INavMeshParameters {
  62734. /**
  62735. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62736. */
  62737. cs: number;
  62738. /**
  62739. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62740. */
  62741. ch: number;
  62742. /**
  62743. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62744. */
  62745. walkableSlopeAngle: number;
  62746. /**
  62747. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62748. * be considered walkable. [Limit: >= 3] [Units: vx]
  62749. */
  62750. walkableHeight: number;
  62751. /**
  62752. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62753. */
  62754. walkableClimb: number;
  62755. /**
  62756. * The distance to erode/shrink the walkable area of the heightfield away from
  62757. * obstructions. [Limit: >=0] [Units: vx]
  62758. */
  62759. walkableRadius: number;
  62760. /**
  62761. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62762. */
  62763. maxEdgeLen: number;
  62764. /**
  62765. * The maximum distance a simplfied contour's border edges should deviate
  62766. * the original raw contour. [Limit: >=0] [Units: vx]
  62767. */
  62768. maxSimplificationError: number;
  62769. /**
  62770. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62771. */
  62772. minRegionArea: number;
  62773. /**
  62774. * Any regions with a span count smaller than this value will, if possible,
  62775. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62776. */
  62777. mergeRegionArea: number;
  62778. /**
  62779. * The maximum number of vertices allowed for polygons generated during the
  62780. * contour to polygon conversion process. [Limit: >= 3]
  62781. */
  62782. maxVertsPerPoly: number;
  62783. /**
  62784. * Sets the sampling distance to use when generating the detail mesh.
  62785. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62786. */
  62787. detailSampleDist: number;
  62788. /**
  62789. * The maximum distance the detail mesh surface should deviate from heightfield
  62790. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62791. */
  62792. detailSampleMaxError: number;
  62793. }
  62794. }
  62795. declare module BABYLON {
  62796. /**
  62797. * RecastJS navigation plugin
  62798. */
  62799. export class RecastJSPlugin implements INavigationEnginePlugin {
  62800. /**
  62801. * Reference to the Recast library
  62802. */
  62803. bjsRECAST: any;
  62804. /**
  62805. * plugin name
  62806. */
  62807. name: string;
  62808. /**
  62809. * the first navmesh created. We might extend this to support multiple navmeshes
  62810. */
  62811. navMesh: any;
  62812. /**
  62813. * Initializes the recastJS plugin
  62814. * @param recastInjection can be used to inject your own recast reference
  62815. */
  62816. constructor(recastInjection?: any);
  62817. /**
  62818. * Creates a navigation mesh
  62819. * @param meshes array of all the geometry used to compute the navigatio mesh
  62820. * @param parameters bunch of parameters used to filter geometry
  62821. */
  62822. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62823. /**
  62824. * Create a navigation mesh debug mesh
  62825. * @param scene is where the mesh will be added
  62826. * @returns debug display mesh
  62827. */
  62828. createDebugNavMesh(scene: Scene): Mesh;
  62829. /**
  62830. * Get a navigation mesh constrained position, closest to the parameter position
  62831. * @param position world position
  62832. * @returns the closest point to position constrained by the navigation mesh
  62833. */
  62834. getClosestPoint(position: Vector3): Vector3;
  62835. /**
  62836. * Get a navigation mesh constrained position, closest to the parameter position
  62837. * @param position world position
  62838. * @param result output the closest point to position constrained by the navigation mesh
  62839. */
  62840. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62841. /**
  62842. * Get a navigation mesh constrained position, within a particular radius
  62843. * @param position world position
  62844. * @param maxRadius the maximum distance to the constrained world position
  62845. * @returns the closest point to position constrained by the navigation mesh
  62846. */
  62847. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62848. /**
  62849. * Get a navigation mesh constrained position, within a particular radius
  62850. * @param position world position
  62851. * @param maxRadius the maximum distance to the constrained world position
  62852. * @param result output the closest point to position constrained by the navigation mesh
  62853. */
  62854. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62855. /**
  62856. * Compute the final position from a segment made of destination-position
  62857. * @param position world position
  62858. * @param destination world position
  62859. * @returns the resulting point along the navmesh
  62860. */
  62861. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62862. /**
  62863. * Compute the final position from a segment made of destination-position
  62864. * @param position world position
  62865. * @param destination world position
  62866. * @param result output the resulting point along the navmesh
  62867. */
  62868. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62869. /**
  62870. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62871. * @param start world position
  62872. * @param end world position
  62873. * @returns array containing world position composing the path
  62874. */
  62875. computePath(start: Vector3, end: Vector3): Vector3[];
  62876. /**
  62877. * Create a new Crowd so you can add agents
  62878. * @param maxAgents the maximum agent count in the crowd
  62879. * @param maxAgentRadius the maximum radius an agent can have
  62880. * @param scene to attach the crowd to
  62881. * @returns the crowd you can add agents to
  62882. */
  62883. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62884. /**
  62885. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62886. * The queries will try to find a solution within those bounds
  62887. * default is (1,1,1)
  62888. * @param extent x,y,z value that define the extent around the queries point of reference
  62889. */
  62890. setDefaultQueryExtent(extent: Vector3): void;
  62891. /**
  62892. * Get the Bounding box extent specified by setDefaultQueryExtent
  62893. * @returns the box extent values
  62894. */
  62895. getDefaultQueryExtent(): Vector3;
  62896. /**
  62897. * build the navmesh from a previously saved state using getNavmeshData
  62898. * @param data the Uint8Array returned by getNavmeshData
  62899. */
  62900. buildFromNavmeshData(data: Uint8Array): void;
  62901. /**
  62902. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62903. * @returns data the Uint8Array that can be saved and reused
  62904. */
  62905. getNavmeshData(): Uint8Array;
  62906. /**
  62907. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62908. * @param result output the box extent values
  62909. */
  62910. getDefaultQueryExtentToRef(result: Vector3): void;
  62911. /**
  62912. * Disposes
  62913. */
  62914. dispose(): void;
  62915. /**
  62916. * If this plugin is supported
  62917. * @returns true if plugin is supported
  62918. */
  62919. isSupported(): boolean;
  62920. }
  62921. /**
  62922. * Recast detour crowd implementation
  62923. */
  62924. export class RecastJSCrowd implements ICrowd {
  62925. /**
  62926. * Recast/detour plugin
  62927. */
  62928. bjsRECASTPlugin: RecastJSPlugin;
  62929. /**
  62930. * Link to the detour crowd
  62931. */
  62932. recastCrowd: any;
  62933. /**
  62934. * One transform per agent
  62935. */
  62936. transforms: TransformNode[];
  62937. /**
  62938. * All agents created
  62939. */
  62940. agents: number[];
  62941. /**
  62942. * Link to the scene is kept to unregister the crowd from the scene
  62943. */
  62944. private _scene;
  62945. /**
  62946. * Observer for crowd updates
  62947. */
  62948. private _onBeforeAnimationsObserver;
  62949. /**
  62950. * Constructor
  62951. * @param plugin recastJS plugin
  62952. * @param maxAgents the maximum agent count in the crowd
  62953. * @param maxAgentRadius the maximum radius an agent can have
  62954. * @param scene to attach the crowd to
  62955. * @returns the crowd you can add agents to
  62956. */
  62957. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62958. /**
  62959. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62960. * You can attach anything to that node. The node position is updated in the scene update tick.
  62961. * @param pos world position that will be constrained by the navigation mesh
  62962. * @param parameters agent parameters
  62963. * @param transform hooked to the agent that will be update by the scene
  62964. * @returns agent index
  62965. */
  62966. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62967. /**
  62968. * Returns the agent position in world space
  62969. * @param index agent index returned by addAgent
  62970. * @returns world space position
  62971. */
  62972. getAgentPosition(index: number): Vector3;
  62973. /**
  62974. * Returns the agent position result in world space
  62975. * @param index agent index returned by addAgent
  62976. * @param result output world space position
  62977. */
  62978. getAgentPositionToRef(index: number, result: Vector3): void;
  62979. /**
  62980. * Returns the agent velocity in world space
  62981. * @param index agent index returned by addAgent
  62982. * @returns world space velocity
  62983. */
  62984. getAgentVelocity(index: number): Vector3;
  62985. /**
  62986. * Returns the agent velocity result in world space
  62987. * @param index agent index returned by addAgent
  62988. * @param result output world space velocity
  62989. */
  62990. getAgentVelocityToRef(index: number, result: Vector3): void;
  62991. /**
  62992. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62993. * @param index agent index returned by addAgent
  62994. * @param destination targeted world position
  62995. */
  62996. agentGoto(index: number, destination: Vector3): void;
  62997. /**
  62998. * Teleport the agent to a new position
  62999. * @param index agent index returned by addAgent
  63000. * @param destination targeted world position
  63001. */
  63002. agentTeleport(index: number, destination: Vector3): void;
  63003. /**
  63004. * Update agent parameters
  63005. * @param index agent index returned by addAgent
  63006. * @param parameters agent parameters
  63007. */
  63008. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63009. /**
  63010. * remove a particular agent previously created
  63011. * @param index agent index returned by addAgent
  63012. */
  63013. removeAgent(index: number): void;
  63014. /**
  63015. * get the list of all agents attached to this crowd
  63016. * @returns list of agent indices
  63017. */
  63018. getAgents(): number[];
  63019. /**
  63020. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63021. * @param deltaTime in seconds
  63022. */
  63023. update(deltaTime: number): void;
  63024. /**
  63025. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63026. * The queries will try to find a solution within those bounds
  63027. * default is (1,1,1)
  63028. * @param extent x,y,z value that define the extent around the queries point of reference
  63029. */
  63030. setDefaultQueryExtent(extent: Vector3): void;
  63031. /**
  63032. * Get the Bounding box extent specified by setDefaultQueryExtent
  63033. * @returns the box extent values
  63034. */
  63035. getDefaultQueryExtent(): Vector3;
  63036. /**
  63037. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63038. * @param result output the box extent values
  63039. */
  63040. getDefaultQueryExtentToRef(result: Vector3): void;
  63041. /**
  63042. * Release all resources
  63043. */
  63044. dispose(): void;
  63045. }
  63046. }
  63047. declare module BABYLON {
  63048. /**
  63049. * Class used to enable access to IndexedDB
  63050. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63051. */
  63052. export class Database implements IOfflineProvider {
  63053. private _callbackManifestChecked;
  63054. private _currentSceneUrl;
  63055. private _db;
  63056. private _enableSceneOffline;
  63057. private _enableTexturesOffline;
  63058. private _manifestVersionFound;
  63059. private _mustUpdateRessources;
  63060. private _hasReachedQuota;
  63061. private _isSupported;
  63062. private _idbFactory;
  63063. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63064. private static IsUASupportingBlobStorage;
  63065. /**
  63066. * Gets a boolean indicating if Database storate is enabled (off by default)
  63067. */
  63068. static IDBStorageEnabled: boolean;
  63069. /**
  63070. * Gets a boolean indicating if scene must be saved in the database
  63071. */
  63072. get enableSceneOffline(): boolean;
  63073. /**
  63074. * Gets a boolean indicating if textures must be saved in the database
  63075. */
  63076. get enableTexturesOffline(): boolean;
  63077. /**
  63078. * Creates a new Database
  63079. * @param urlToScene defines the url to load the scene
  63080. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63081. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63082. */
  63083. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63084. private static _ParseURL;
  63085. private static _ReturnFullUrlLocation;
  63086. private _checkManifestFile;
  63087. /**
  63088. * Open the database and make it available
  63089. * @param successCallback defines the callback to call on success
  63090. * @param errorCallback defines the callback to call on error
  63091. */
  63092. open(successCallback: () => void, errorCallback: () => void): void;
  63093. /**
  63094. * Loads an image from the database
  63095. * @param url defines the url to load from
  63096. * @param image defines the target DOM image
  63097. */
  63098. loadImage(url: string, image: HTMLImageElement): void;
  63099. private _loadImageFromDBAsync;
  63100. private _saveImageIntoDBAsync;
  63101. private _checkVersionFromDB;
  63102. private _loadVersionFromDBAsync;
  63103. private _saveVersionIntoDBAsync;
  63104. /**
  63105. * Loads a file from database
  63106. * @param url defines the URL to load from
  63107. * @param sceneLoaded defines a callback to call on success
  63108. * @param progressCallBack defines a callback to call when progress changed
  63109. * @param errorCallback defines a callback to call on error
  63110. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63111. */
  63112. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63113. private _loadFileAsync;
  63114. private _saveFileAsync;
  63115. /**
  63116. * Validates if xhr data is correct
  63117. * @param xhr defines the request to validate
  63118. * @param dataType defines the expected data type
  63119. * @returns true if data is correct
  63120. */
  63121. private static _ValidateXHRData;
  63122. }
  63123. }
  63124. declare module BABYLON {
  63125. /** @hidden */
  63126. export var gpuUpdateParticlesPixelShader: {
  63127. name: string;
  63128. shader: string;
  63129. };
  63130. }
  63131. declare module BABYLON {
  63132. /** @hidden */
  63133. export var gpuUpdateParticlesVertexShader: {
  63134. name: string;
  63135. shader: string;
  63136. };
  63137. }
  63138. declare module BABYLON {
  63139. /** @hidden */
  63140. export var clipPlaneFragmentDeclaration2: {
  63141. name: string;
  63142. shader: string;
  63143. };
  63144. }
  63145. declare module BABYLON {
  63146. /** @hidden */
  63147. export var gpuRenderParticlesPixelShader: {
  63148. name: string;
  63149. shader: string;
  63150. };
  63151. }
  63152. declare module BABYLON {
  63153. /** @hidden */
  63154. export var clipPlaneVertexDeclaration2: {
  63155. name: string;
  63156. shader: string;
  63157. };
  63158. }
  63159. declare module BABYLON {
  63160. /** @hidden */
  63161. export var gpuRenderParticlesVertexShader: {
  63162. name: string;
  63163. shader: string;
  63164. };
  63165. }
  63166. declare module BABYLON {
  63167. /**
  63168. * This represents a GPU particle system in Babylon
  63169. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63170. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63171. */
  63172. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63173. /**
  63174. * The layer mask we are rendering the particles through.
  63175. */
  63176. layerMask: number;
  63177. private _capacity;
  63178. private _activeCount;
  63179. private _currentActiveCount;
  63180. private _accumulatedCount;
  63181. private _renderEffect;
  63182. private _updateEffect;
  63183. private _buffer0;
  63184. private _buffer1;
  63185. private _spriteBuffer;
  63186. private _updateVAO;
  63187. private _renderVAO;
  63188. private _targetIndex;
  63189. private _sourceBuffer;
  63190. private _targetBuffer;
  63191. private _engine;
  63192. private _currentRenderId;
  63193. private _started;
  63194. private _stopped;
  63195. private _timeDelta;
  63196. private _randomTexture;
  63197. private _randomTexture2;
  63198. private _attributesStrideSize;
  63199. private _updateEffectOptions;
  63200. private _randomTextureSize;
  63201. private _actualFrame;
  63202. private readonly _rawTextureWidth;
  63203. /**
  63204. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63205. */
  63206. static get IsSupported(): boolean;
  63207. /**
  63208. * An event triggered when the system is disposed.
  63209. */
  63210. onDisposeObservable: Observable<GPUParticleSystem>;
  63211. /**
  63212. * Gets the maximum number of particles active at the same time.
  63213. * @returns The max number of active particles.
  63214. */
  63215. getCapacity(): number;
  63216. /**
  63217. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63218. * to override the particles.
  63219. */
  63220. forceDepthWrite: boolean;
  63221. /**
  63222. * Gets or set the number of active particles
  63223. */
  63224. get activeParticleCount(): number;
  63225. set activeParticleCount(value: number);
  63226. private _preWarmDone;
  63227. /**
  63228. * Specifies if the particles are updated in emitter local space or world space.
  63229. * This is always false for GPU particles
  63230. */
  63231. get isLocal(): boolean;
  63232. set isLocal(value: boolean);
  63233. /**
  63234. * Is this system ready to be used/rendered
  63235. * @return true if the system is ready
  63236. */
  63237. isReady(): boolean;
  63238. /**
  63239. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63240. * @returns True if it has been started, otherwise false.
  63241. */
  63242. isStarted(): boolean;
  63243. /**
  63244. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63245. * @returns True if it has been stopped, otherwise false.
  63246. */
  63247. isStopped(): boolean;
  63248. /**
  63249. * Gets a boolean indicating that the system is stopping
  63250. * @returns true if the system is currently stopping
  63251. */
  63252. isStopping(): boolean;
  63253. /**
  63254. * Gets the number of particles active at the same time.
  63255. * @returns The number of active particles.
  63256. */
  63257. getActiveCount(): number;
  63258. /**
  63259. * Starts the particle system and begins to emit
  63260. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63261. */
  63262. start(delay?: number): void;
  63263. /**
  63264. * Stops the particle system.
  63265. */
  63266. stop(): void;
  63267. /**
  63268. * Remove all active particles
  63269. */
  63270. reset(): void;
  63271. /**
  63272. * Returns the string "GPUParticleSystem"
  63273. * @returns a string containing the class name
  63274. */
  63275. getClassName(): string;
  63276. private _colorGradientsTexture;
  63277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63278. /**
  63279. * Adds a new color gradient
  63280. * @param gradient defines the gradient to use (between 0 and 1)
  63281. * @param color1 defines the color to affect to the specified gradient
  63282. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63283. * @returns the current particle system
  63284. */
  63285. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63286. private _refreshColorGradient;
  63287. /** Force the system to rebuild all gradients that need to be resync */
  63288. forceRefreshGradients(): void;
  63289. /**
  63290. * Remove a specific color gradient
  63291. * @param gradient defines the gradient to remove
  63292. * @returns the current particle system
  63293. */
  63294. removeColorGradient(gradient: number): GPUParticleSystem;
  63295. private _angularSpeedGradientsTexture;
  63296. private _sizeGradientsTexture;
  63297. private _velocityGradientsTexture;
  63298. private _limitVelocityGradientsTexture;
  63299. private _dragGradientsTexture;
  63300. private _addFactorGradient;
  63301. /**
  63302. * Adds a new size gradient
  63303. * @param gradient defines the gradient to use (between 0 and 1)
  63304. * @param factor defines the size factor to affect to the specified gradient
  63305. * @returns the current particle system
  63306. */
  63307. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63308. /**
  63309. * Remove a specific size gradient
  63310. * @param gradient defines the gradient to remove
  63311. * @returns the current particle system
  63312. */
  63313. removeSizeGradient(gradient: number): GPUParticleSystem;
  63314. private _refreshFactorGradient;
  63315. /**
  63316. * Adds a new angular speed gradient
  63317. * @param gradient defines the gradient to use (between 0 and 1)
  63318. * @param factor defines the angular speed to affect to the specified gradient
  63319. * @returns the current particle system
  63320. */
  63321. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63322. /**
  63323. * Remove a specific angular speed gradient
  63324. * @param gradient defines the gradient to remove
  63325. * @returns the current particle system
  63326. */
  63327. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63328. /**
  63329. * Adds a new velocity gradient
  63330. * @param gradient defines the gradient to use (between 0 and 1)
  63331. * @param factor defines the velocity to affect to the specified gradient
  63332. * @returns the current particle system
  63333. */
  63334. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63335. /**
  63336. * Remove a specific velocity gradient
  63337. * @param gradient defines the gradient to remove
  63338. * @returns the current particle system
  63339. */
  63340. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63341. /**
  63342. * Adds a new limit velocity gradient
  63343. * @param gradient defines the gradient to use (between 0 and 1)
  63344. * @param factor defines the limit velocity value to affect to the specified gradient
  63345. * @returns the current particle system
  63346. */
  63347. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63348. /**
  63349. * Remove a specific limit velocity gradient
  63350. * @param gradient defines the gradient to remove
  63351. * @returns the current particle system
  63352. */
  63353. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63354. /**
  63355. * Adds a new drag gradient
  63356. * @param gradient defines the gradient to use (between 0 and 1)
  63357. * @param factor defines the drag value to affect to the specified gradient
  63358. * @returns the current particle system
  63359. */
  63360. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63361. /**
  63362. * Remove a specific drag gradient
  63363. * @param gradient defines the gradient to remove
  63364. * @returns the current particle system
  63365. */
  63366. removeDragGradient(gradient: number): GPUParticleSystem;
  63367. /**
  63368. * Not supported by GPUParticleSystem
  63369. * @param gradient defines the gradient to use (between 0 and 1)
  63370. * @param factor defines the emit rate value to affect to the specified gradient
  63371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63372. * @returns the current particle system
  63373. */
  63374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63375. /**
  63376. * Not supported by GPUParticleSystem
  63377. * @param gradient defines the gradient to remove
  63378. * @returns the current particle system
  63379. */
  63380. removeEmitRateGradient(gradient: number): IParticleSystem;
  63381. /**
  63382. * Not supported by GPUParticleSystem
  63383. * @param gradient defines the gradient to use (between 0 and 1)
  63384. * @param factor defines the start size value to affect to the specified gradient
  63385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63386. * @returns the current particle system
  63387. */
  63388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63389. /**
  63390. * Not supported by GPUParticleSystem
  63391. * @param gradient defines the gradient to remove
  63392. * @returns the current particle system
  63393. */
  63394. removeStartSizeGradient(gradient: number): IParticleSystem;
  63395. /**
  63396. * Not supported by GPUParticleSystem
  63397. * @param gradient defines the gradient to use (between 0 and 1)
  63398. * @param min defines the color remap minimal range
  63399. * @param max defines the color remap maximal range
  63400. * @returns the current particle system
  63401. */
  63402. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63403. /**
  63404. * Not supported by GPUParticleSystem
  63405. * @param gradient defines the gradient to remove
  63406. * @returns the current particle system
  63407. */
  63408. removeColorRemapGradient(): IParticleSystem;
  63409. /**
  63410. * Not supported by GPUParticleSystem
  63411. * @param gradient defines the gradient to use (between 0 and 1)
  63412. * @param min defines the alpha remap minimal range
  63413. * @param max defines the alpha remap maximal range
  63414. * @returns the current particle system
  63415. */
  63416. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63417. /**
  63418. * Not supported by GPUParticleSystem
  63419. * @param gradient defines the gradient to remove
  63420. * @returns the current particle system
  63421. */
  63422. removeAlphaRemapGradient(): IParticleSystem;
  63423. /**
  63424. * Not supported by GPUParticleSystem
  63425. * @param gradient defines the gradient to use (between 0 and 1)
  63426. * @param color defines the color to affect to the specified gradient
  63427. * @returns the current particle system
  63428. */
  63429. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63430. /**
  63431. * Not supported by GPUParticleSystem
  63432. * @param gradient defines the gradient to remove
  63433. * @returns the current particle system
  63434. */
  63435. removeRampGradient(): IParticleSystem;
  63436. /**
  63437. * Not supported by GPUParticleSystem
  63438. * @returns the list of ramp gradients
  63439. */
  63440. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63441. /**
  63442. * Not supported by GPUParticleSystem
  63443. * Gets or sets a boolean indicating that ramp gradients must be used
  63444. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63445. */
  63446. get useRampGradients(): boolean;
  63447. set useRampGradients(value: boolean);
  63448. /**
  63449. * Not supported by GPUParticleSystem
  63450. * @param gradient defines the gradient to use (between 0 and 1)
  63451. * @param factor defines the life time factor to affect to the specified gradient
  63452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63453. * @returns the current particle system
  63454. */
  63455. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63456. /**
  63457. * Not supported by GPUParticleSystem
  63458. * @param gradient defines the gradient to remove
  63459. * @returns the current particle system
  63460. */
  63461. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63462. /**
  63463. * Instantiates a GPU particle system.
  63464. * 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.
  63465. * @param name The name of the particle system
  63466. * @param options The options used to create the system
  63467. * @param scene The scene the particle system belongs to
  63468. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63469. */
  63470. constructor(name: string, options: Partial<{
  63471. capacity: number;
  63472. randomTextureSize: number;
  63473. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63474. protected _reset(): void;
  63475. private _createUpdateVAO;
  63476. private _createRenderVAO;
  63477. private _initialize;
  63478. /** @hidden */
  63479. _recreateUpdateEffect(): void;
  63480. /** @hidden */
  63481. _recreateRenderEffect(): void;
  63482. /**
  63483. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63484. * @param preWarm defines if we are in the pre-warmimg phase
  63485. */
  63486. animate(preWarm?: boolean): void;
  63487. private _createFactorGradientTexture;
  63488. private _createSizeGradientTexture;
  63489. private _createAngularSpeedGradientTexture;
  63490. private _createVelocityGradientTexture;
  63491. private _createLimitVelocityGradientTexture;
  63492. private _createDragGradientTexture;
  63493. private _createColorGradientTexture;
  63494. /**
  63495. * Renders the particle system in its current state
  63496. * @param preWarm defines if the system should only update the particles but not render them
  63497. * @returns the current number of particles
  63498. */
  63499. render(preWarm?: boolean): number;
  63500. /**
  63501. * Rebuilds the particle system
  63502. */
  63503. rebuild(): void;
  63504. private _releaseBuffers;
  63505. private _releaseVAOs;
  63506. /**
  63507. * Disposes the particle system and free the associated resources
  63508. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63509. */
  63510. dispose(disposeTexture?: boolean): void;
  63511. /**
  63512. * Clones the particle system.
  63513. * @param name The name of the cloned object
  63514. * @param newEmitter The new emitter to use
  63515. * @returns the cloned particle system
  63516. */
  63517. clone(name: string, newEmitter: any): GPUParticleSystem;
  63518. /**
  63519. * Serializes the particle system to a JSON object
  63520. * @param serializeTexture defines if the texture must be serialized as well
  63521. * @returns the JSON object
  63522. */
  63523. serialize(serializeTexture?: boolean): any;
  63524. /**
  63525. * Parses a JSON object to create a GPU particle system.
  63526. * @param parsedParticleSystem The JSON object to parse
  63527. * @param scene The scene to create the particle system in
  63528. * @param rootUrl The root url to use to load external dependencies like texture
  63529. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63530. * @returns the parsed GPU particle system
  63531. */
  63532. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /**
  63537. * Represents a set of particle systems working together to create a specific effect
  63538. */
  63539. export class ParticleSystemSet implements IDisposable {
  63540. /**
  63541. * Gets or sets base Assets URL
  63542. */
  63543. static BaseAssetsUrl: string;
  63544. private _emitterCreationOptions;
  63545. private _emitterNode;
  63546. /**
  63547. * Gets the particle system list
  63548. */
  63549. systems: IParticleSystem[];
  63550. /**
  63551. * Gets the emitter node used with this set
  63552. */
  63553. get emitterNode(): Nullable<TransformNode>;
  63554. /**
  63555. * Creates a new emitter mesh as a sphere
  63556. * @param options defines the options used to create the sphere
  63557. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63558. * @param scene defines the hosting scene
  63559. */
  63560. setEmitterAsSphere(options: {
  63561. diameter: number;
  63562. segments: number;
  63563. color: Color3;
  63564. }, renderingGroupId: number, scene: Scene): void;
  63565. /**
  63566. * Starts all particle systems of the set
  63567. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63568. */
  63569. start(emitter?: AbstractMesh): void;
  63570. /**
  63571. * Release all associated resources
  63572. */
  63573. dispose(): void;
  63574. /**
  63575. * Serialize the set into a JSON compatible object
  63576. * @param serializeTexture defines if the texture must be serialized as well
  63577. * @returns a JSON compatible representation of the set
  63578. */
  63579. serialize(serializeTexture?: boolean): any;
  63580. /**
  63581. * Parse a new ParticleSystemSet from a serialized source
  63582. * @param data defines a JSON compatible representation of the set
  63583. * @param scene defines the hosting scene
  63584. * @param gpu defines if we want GPU particles or CPU particles
  63585. * @returns a new ParticleSystemSet
  63586. */
  63587. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * This class is made for on one-liner static method to help creating particle system set.
  63593. */
  63594. export class ParticleHelper {
  63595. /**
  63596. * Gets or sets base Assets URL
  63597. */
  63598. static BaseAssetsUrl: string;
  63599. /** Define the Url to load snippets */
  63600. static SnippetUrl: string;
  63601. /**
  63602. * Create a default particle system that you can tweak
  63603. * @param emitter defines the emitter to use
  63604. * @param capacity defines the system capacity (default is 500 particles)
  63605. * @param scene defines the hosting scene
  63606. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63607. * @returns the new Particle system
  63608. */
  63609. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63610. /**
  63611. * This is the main static method (one-liner) of this helper to create different particle systems
  63612. * @param type This string represents the type to the particle system to create
  63613. * @param scene The scene where the particle system should live
  63614. * @param gpu If the system will use gpu
  63615. * @returns the ParticleSystemSet created
  63616. */
  63617. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63618. /**
  63619. * Static function used to export a particle system to a ParticleSystemSet variable.
  63620. * Please note that the emitter shape is not exported
  63621. * @param systems defines the particle systems to export
  63622. * @returns the created particle system set
  63623. */
  63624. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63625. /**
  63626. * Creates a particle system from a snippet saved in a remote file
  63627. * @param name defines the name of the particle system to create
  63628. * @param url defines the url to load from
  63629. * @param scene defines the hosting scene
  63630. * @param gpu If the system will use gpu
  63631. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63632. * @returns a promise that will resolve to the new particle system
  63633. */
  63634. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63635. /**
  63636. * Creates a particle system from a snippet saved by the particle system editor
  63637. * @param snippetId defines the snippet to load
  63638. * @param scene defines the hosting scene
  63639. * @param gpu If the system will use gpu
  63640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63641. * @returns a promise that will resolve to the new particle system
  63642. */
  63643. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. interface Engine {
  63648. /**
  63649. * Create an effect to use with particle systems.
  63650. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63651. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63652. * @param uniformsNames defines a list of attribute names
  63653. * @param samplers defines an array of string used to represent textures
  63654. * @param defines defines the string containing the defines to use to compile the shaders
  63655. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63656. * @param onCompiled defines a function to call when the effect creation is successful
  63657. * @param onError defines a function to call when the effect creation has failed
  63658. * @returns the new Effect
  63659. */
  63660. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63661. }
  63662. interface Mesh {
  63663. /**
  63664. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63665. * @returns an array of IParticleSystem
  63666. */
  63667. getEmittedParticleSystems(): IParticleSystem[];
  63668. /**
  63669. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63670. * @returns an array of IParticleSystem
  63671. */
  63672. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63673. }
  63674. /**
  63675. * @hidden
  63676. */
  63677. export var _IDoNeedToBeInTheBuild: number;
  63678. }
  63679. declare module BABYLON {
  63680. /** Defines the 4 color options */
  63681. export enum PointColor {
  63682. /** color value */
  63683. Color = 2,
  63684. /** uv value */
  63685. UV = 1,
  63686. /** random value */
  63687. Random = 0,
  63688. /** stated value */
  63689. Stated = 3
  63690. }
  63691. /**
  63692. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63693. * 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.
  63694. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63695. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63696. *
  63697. * Full documentation here : TO BE ENTERED
  63698. */
  63699. export class PointsCloudSystem implements IDisposable {
  63700. /**
  63701. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63702. * Example : var p = SPS.particles[i];
  63703. */
  63704. particles: CloudPoint[];
  63705. /**
  63706. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63707. */
  63708. nbParticles: number;
  63709. /**
  63710. * This a counter for your own usage. It's not set by any SPS functions.
  63711. */
  63712. counter: number;
  63713. /**
  63714. * The PCS name. This name is also given to the underlying mesh.
  63715. */
  63716. name: string;
  63717. /**
  63718. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63719. */
  63720. mesh: Mesh;
  63721. /**
  63722. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63723. * Please read :
  63724. */
  63725. vars: any;
  63726. /**
  63727. * @hidden
  63728. */
  63729. _size: number;
  63730. private _scene;
  63731. private _promises;
  63732. private _positions;
  63733. private _indices;
  63734. private _normals;
  63735. private _colors;
  63736. private _uvs;
  63737. private _indices32;
  63738. private _positions32;
  63739. private _colors32;
  63740. private _uvs32;
  63741. private _updatable;
  63742. private _isVisibilityBoxLocked;
  63743. private _alwaysVisible;
  63744. private _groups;
  63745. private _groupCounter;
  63746. private _computeParticleColor;
  63747. private _computeParticleTexture;
  63748. private _computeParticleRotation;
  63749. private _computeBoundingBox;
  63750. private _isReady;
  63751. /**
  63752. * Creates a PCS (Points Cloud System) object
  63753. * @param name (String) is the PCS name, this will be the underlying mesh name
  63754. * @param pointSize (number) is the size for each point
  63755. * @param scene (Scene) is the scene in which the PCS is added
  63756. * @param options defines the options of the PCS e.g.
  63757. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63758. */
  63759. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63760. updatable?: boolean;
  63761. });
  63762. /**
  63763. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63764. * If no points were added to the PCS, the returned mesh is just a single point.
  63765. * @returns a promise for the created mesh
  63766. */
  63767. buildMeshAsync(): Promise<Mesh>;
  63768. /**
  63769. * @hidden
  63770. */
  63771. private _buildMesh;
  63772. private _addParticle;
  63773. private _randomUnitVector;
  63774. private _getColorIndicesForCoord;
  63775. private _setPointsColorOrUV;
  63776. private _colorFromTexture;
  63777. private _calculateDensity;
  63778. /**
  63779. * Adds points to the PCS in random positions within a unit sphere
  63780. * @param nb (positive integer) the number of particles to be created from this model
  63781. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63782. * @returns the number of groups in the system
  63783. */
  63784. addPoints(nb: number, pointFunction?: any): number;
  63785. /**
  63786. * Adds points to the PCS from the surface of the model shape
  63787. * @param mesh is any Mesh object that will be used as a surface model for the points
  63788. * @param nb (positive integer) the number of particles to be created from this model
  63789. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63790. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63791. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63792. * @returns the number of groups in the system
  63793. */
  63794. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63795. /**
  63796. * Adds points to the PCS inside the model shape
  63797. * @param mesh is any Mesh object that will be used as a surface model for the points
  63798. * @param nb (positive integer) the number of particles to be created from this model
  63799. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63800. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63801. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63802. * @returns the number of groups in the system
  63803. */
  63804. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63805. /**
  63806. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63807. * This method calls `updateParticle()` for each particle of the SPS.
  63808. * For an animated SPS, it is usually called within the render loop.
  63809. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63810. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63811. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63812. * @returns the PCS.
  63813. */
  63814. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63815. /**
  63816. * Disposes the PCS.
  63817. */
  63818. dispose(): void;
  63819. /**
  63820. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63821. * doc :
  63822. * @returns the PCS.
  63823. */
  63824. refreshVisibleSize(): PointsCloudSystem;
  63825. /**
  63826. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63827. * @param size the size (float) of the visibility box
  63828. * note : this doesn't lock the PCS mesh bounding box.
  63829. * doc :
  63830. */
  63831. setVisibilityBox(size: number): void;
  63832. /**
  63833. * Gets whether the PCS is always visible or not
  63834. * doc :
  63835. */
  63836. get isAlwaysVisible(): boolean;
  63837. /**
  63838. * Sets the PCS as always visible or not
  63839. * doc :
  63840. */
  63841. set isAlwaysVisible(val: boolean);
  63842. /**
  63843. * Tells to `setParticles()` to compute the particle rotations or not
  63844. * Default value : false. The PCS is faster when it's set to false
  63845. * Note : particle rotations are only applied to parent particles
  63846. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63847. */
  63848. set computeParticleRotation(val: boolean);
  63849. /**
  63850. * Tells to `setParticles()` to compute the particle colors or not.
  63851. * Default value : true. The PCS is faster when it's set to false.
  63852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63853. */
  63854. set computeParticleColor(val: boolean);
  63855. set computeParticleTexture(val: boolean);
  63856. /**
  63857. * Gets if `setParticles()` computes the particle colors or not.
  63858. * Default value : false. The PCS is faster when it's set to false.
  63859. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63860. */
  63861. get computeParticleColor(): boolean;
  63862. /**
  63863. * Gets if `setParticles()` computes the particle textures or not.
  63864. * Default value : false. The PCS is faster when it's set to false.
  63865. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63866. */
  63867. get computeParticleTexture(): boolean;
  63868. /**
  63869. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63870. */
  63871. set computeBoundingBox(val: boolean);
  63872. /**
  63873. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63874. */
  63875. get computeBoundingBox(): boolean;
  63876. /**
  63877. * This function does nothing. It may be overwritten to set all the particle first values.
  63878. * The PCS doesn't call this function, you may have to call it by your own.
  63879. * doc :
  63880. */
  63881. initParticles(): void;
  63882. /**
  63883. * This function does nothing. It may be overwritten to recycle a particle
  63884. * The PCS doesn't call this function, you can to call it
  63885. * doc :
  63886. * @param particle The particle to recycle
  63887. * @returns the recycled particle
  63888. */
  63889. recycleParticle(particle: CloudPoint): CloudPoint;
  63890. /**
  63891. * Updates a particle : this function should be overwritten by the user.
  63892. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63893. * doc :
  63894. * @example : just set a particle position or velocity and recycle conditions
  63895. * @param particle The particle to update
  63896. * @returns the updated particle
  63897. */
  63898. updateParticle(particle: CloudPoint): CloudPoint;
  63899. /**
  63900. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63901. * This does nothing and may be overwritten by the user.
  63902. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63903. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63904. * @param update the boolean update value actually passed to setParticles()
  63905. */
  63906. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63907. /**
  63908. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63909. * This will be passed three parameters.
  63910. * This does nothing and may be overwritten by the user.
  63911. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63912. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63913. * @param update the boolean update value actually passed to setParticles()
  63914. */
  63915. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63916. }
  63917. }
  63918. declare module BABYLON {
  63919. /**
  63920. * Represents one particle of a points cloud system.
  63921. */
  63922. export class CloudPoint {
  63923. /**
  63924. * particle global index
  63925. */
  63926. idx: number;
  63927. /**
  63928. * The color of the particle
  63929. */
  63930. color: Nullable<Color4>;
  63931. /**
  63932. * The world space position of the particle.
  63933. */
  63934. position: Vector3;
  63935. /**
  63936. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63937. */
  63938. rotation: Vector3;
  63939. /**
  63940. * The world space rotation quaternion of the particle.
  63941. */
  63942. rotationQuaternion: Nullable<Quaternion>;
  63943. /**
  63944. * The uv of the particle.
  63945. */
  63946. uv: Nullable<Vector2>;
  63947. /**
  63948. * The current speed of the particle.
  63949. */
  63950. velocity: Vector3;
  63951. /**
  63952. * The pivot point in the particle local space.
  63953. */
  63954. pivot: Vector3;
  63955. /**
  63956. * Must the particle be translated from its pivot point in its local space ?
  63957. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63958. * Default : false
  63959. */
  63960. translateFromPivot: boolean;
  63961. /**
  63962. * Index of this particle in the global "positions" array (Internal use)
  63963. * @hidden
  63964. */
  63965. _pos: number;
  63966. /**
  63967. * @hidden Index of this particle in the global "indices" array (Internal use)
  63968. */
  63969. _ind: number;
  63970. /**
  63971. * Group this particle belongs to
  63972. */
  63973. _group: PointsGroup;
  63974. /**
  63975. * Group id of this particle
  63976. */
  63977. groupId: number;
  63978. /**
  63979. * Index of the particle in its group id (Internal use)
  63980. */
  63981. idxInGroup: number;
  63982. /**
  63983. * @hidden Particle BoundingInfo object (Internal use)
  63984. */
  63985. _boundingInfo: BoundingInfo;
  63986. /**
  63987. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63988. */
  63989. _pcs: PointsCloudSystem;
  63990. /**
  63991. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63992. */
  63993. _stillInvisible: boolean;
  63994. /**
  63995. * @hidden Last computed particle rotation matrix
  63996. */
  63997. _rotationMatrix: number[];
  63998. /**
  63999. * Parent particle Id, if any.
  64000. * Default null.
  64001. */
  64002. parentId: Nullable<number>;
  64003. /**
  64004. * @hidden Internal global position in the PCS.
  64005. */
  64006. _globalPosition: Vector3;
  64007. /**
  64008. * Creates a Point Cloud object.
  64009. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64010. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64011. * @param group (PointsGroup) is the group the particle belongs to
  64012. * @param groupId (integer) is the group identifier in the PCS.
  64013. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64014. * @param pcs defines the PCS it is associated to
  64015. */
  64016. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64017. /**
  64018. * get point size
  64019. */
  64020. get size(): Vector3;
  64021. /**
  64022. * Set point size
  64023. */
  64024. set size(scale: Vector3);
  64025. /**
  64026. * Legacy support, changed quaternion to rotationQuaternion
  64027. */
  64028. get quaternion(): Nullable<Quaternion>;
  64029. /**
  64030. * Legacy support, changed quaternion to rotationQuaternion
  64031. */
  64032. set quaternion(q: Nullable<Quaternion>);
  64033. /**
  64034. * Returns a boolean. True if the particle intersects a mesh, else false
  64035. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64036. * @param target is the object (point or mesh) what the intersection is computed against
  64037. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64038. * @returns true if it intersects
  64039. */
  64040. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64041. /**
  64042. * get the rotation matrix of the particle
  64043. * @hidden
  64044. */
  64045. getRotationMatrix(m: Matrix): void;
  64046. }
  64047. /**
  64048. * Represents a group of points in a points cloud system
  64049. * * PCS internal tool, don't use it manually.
  64050. */
  64051. export class PointsGroup {
  64052. /**
  64053. * The group id
  64054. * @hidden
  64055. */
  64056. groupID: number;
  64057. /**
  64058. * image data for group (internal use)
  64059. * @hidden
  64060. */
  64061. _groupImageData: Nullable<ArrayBufferView>;
  64062. /**
  64063. * Image Width (internal use)
  64064. * @hidden
  64065. */
  64066. _groupImgWidth: number;
  64067. /**
  64068. * Image Height (internal use)
  64069. * @hidden
  64070. */
  64071. _groupImgHeight: number;
  64072. /**
  64073. * Custom position function (internal use)
  64074. * @hidden
  64075. */
  64076. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64077. /**
  64078. * density per facet for surface points
  64079. * @hidden
  64080. */
  64081. _groupDensity: number[];
  64082. /**
  64083. * Only when points are colored by texture carries pointer to texture list array
  64084. * @hidden
  64085. */
  64086. _textureNb: number;
  64087. /**
  64088. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64089. * PCS internal tool, don't use it manually.
  64090. * @hidden
  64091. */
  64092. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64093. }
  64094. }
  64095. declare module BABYLON {
  64096. interface Scene {
  64097. /** @hidden (Backing field) */
  64098. _physicsEngine: Nullable<IPhysicsEngine>;
  64099. /** @hidden */
  64100. _physicsTimeAccumulator: number;
  64101. /**
  64102. * Gets the current physics engine
  64103. * @returns a IPhysicsEngine or null if none attached
  64104. */
  64105. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64106. /**
  64107. * Enables physics to the current scene
  64108. * @param gravity defines the scene's gravity for the physics engine
  64109. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64110. * @return a boolean indicating if the physics engine was initialized
  64111. */
  64112. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64113. /**
  64114. * Disables and disposes the physics engine associated with the scene
  64115. */
  64116. disablePhysicsEngine(): void;
  64117. /**
  64118. * Gets a boolean indicating if there is an active physics engine
  64119. * @returns a boolean indicating if there is an active physics engine
  64120. */
  64121. isPhysicsEnabled(): boolean;
  64122. /**
  64123. * Deletes a physics compound impostor
  64124. * @param compound defines the compound to delete
  64125. */
  64126. deleteCompoundImpostor(compound: any): void;
  64127. /**
  64128. * An event triggered when physic simulation is about to be run
  64129. */
  64130. onBeforePhysicsObservable: Observable<Scene>;
  64131. /**
  64132. * An event triggered when physic simulation has been done
  64133. */
  64134. onAfterPhysicsObservable: Observable<Scene>;
  64135. }
  64136. interface AbstractMesh {
  64137. /** @hidden */
  64138. _physicsImpostor: Nullable<PhysicsImpostor>;
  64139. /**
  64140. * Gets or sets impostor used for physic simulation
  64141. * @see http://doc.babylonjs.com/features/physics_engine
  64142. */
  64143. physicsImpostor: Nullable<PhysicsImpostor>;
  64144. /**
  64145. * Gets the current physics impostor
  64146. * @see http://doc.babylonjs.com/features/physics_engine
  64147. * @returns a physics impostor or null
  64148. */
  64149. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64150. /** Apply a physic impulse to the mesh
  64151. * @param force defines the force to apply
  64152. * @param contactPoint defines where to apply the force
  64153. * @returns the current mesh
  64154. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64155. */
  64156. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64157. /**
  64158. * Creates a physic joint between two meshes
  64159. * @param otherMesh defines the other mesh to use
  64160. * @param pivot1 defines the pivot to use on this mesh
  64161. * @param pivot2 defines the pivot to use on the other mesh
  64162. * @param options defines additional options (can be plugin dependent)
  64163. * @returns the current mesh
  64164. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64165. */
  64166. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64167. /** @hidden */
  64168. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64169. }
  64170. /**
  64171. * Defines the physics engine scene component responsible to manage a physics engine
  64172. */
  64173. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64174. /**
  64175. * The component name helpful to identify the component in the list of scene components.
  64176. */
  64177. readonly name: string;
  64178. /**
  64179. * The scene the component belongs to.
  64180. */
  64181. scene: Scene;
  64182. /**
  64183. * Creates a new instance of the component for the given scene
  64184. * @param scene Defines the scene to register the component in
  64185. */
  64186. constructor(scene: Scene);
  64187. /**
  64188. * Registers the component in a given scene
  64189. */
  64190. register(): void;
  64191. /**
  64192. * Rebuilds the elements related to this component in case of
  64193. * context lost for instance.
  64194. */
  64195. rebuild(): void;
  64196. /**
  64197. * Disposes the component and the associated ressources
  64198. */
  64199. dispose(): void;
  64200. }
  64201. }
  64202. declare module BABYLON {
  64203. /**
  64204. * A helper for physics simulations
  64205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64206. */
  64207. export class PhysicsHelper {
  64208. private _scene;
  64209. private _physicsEngine;
  64210. /**
  64211. * Initializes the Physics helper
  64212. * @param scene Babylon.js scene
  64213. */
  64214. constructor(scene: Scene);
  64215. /**
  64216. * Applies a radial explosion impulse
  64217. * @param origin the origin of the explosion
  64218. * @param radiusOrEventOptions the radius or the options of radial explosion
  64219. * @param strength the explosion strength
  64220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64221. * @returns A physics radial explosion event, or null
  64222. */
  64223. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64224. /**
  64225. * Applies a radial explosion force
  64226. * @param origin the origin of the explosion
  64227. * @param radiusOrEventOptions the radius or the options of radial explosion
  64228. * @param strength the explosion strength
  64229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64230. * @returns A physics radial explosion event, or null
  64231. */
  64232. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64233. /**
  64234. * Creates a gravitational field
  64235. * @param origin the origin of the explosion
  64236. * @param radiusOrEventOptions the radius or the options of radial explosion
  64237. * @param strength the explosion strength
  64238. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64239. * @returns A physics gravitational field event, or null
  64240. */
  64241. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64242. /**
  64243. * Creates a physics updraft event
  64244. * @param origin the origin of the updraft
  64245. * @param radiusOrEventOptions the radius or the options of the updraft
  64246. * @param strength the strength of the updraft
  64247. * @param height the height of the updraft
  64248. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64249. * @returns A physics updraft event, or null
  64250. */
  64251. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64252. /**
  64253. * Creates a physics vortex event
  64254. * @param origin the of the vortex
  64255. * @param radiusOrEventOptions the radius or the options of the vortex
  64256. * @param strength the strength of the vortex
  64257. * @param height the height of the vortex
  64258. * @returns a Physics vortex event, or null
  64259. * A physics vortex event or null
  64260. */
  64261. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64262. }
  64263. /**
  64264. * Represents a physics radial explosion event
  64265. */
  64266. class PhysicsRadialExplosionEvent {
  64267. private _scene;
  64268. private _options;
  64269. private _sphere;
  64270. private _dataFetched;
  64271. /**
  64272. * Initializes a radial explosioin event
  64273. * @param _scene BabylonJS scene
  64274. * @param _options The options for the vortex event
  64275. */
  64276. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64277. /**
  64278. * Returns the data related to the radial explosion event (sphere).
  64279. * @returns The radial explosion event data
  64280. */
  64281. getData(): PhysicsRadialExplosionEventData;
  64282. /**
  64283. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64284. * @param impostor A physics imposter
  64285. * @param origin the origin of the explosion
  64286. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64287. */
  64288. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64289. /**
  64290. * Triggers affecterd impostors callbacks
  64291. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64292. */
  64293. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64294. /**
  64295. * Disposes the sphere.
  64296. * @param force Specifies if the sphere should be disposed by force
  64297. */
  64298. dispose(force?: boolean): void;
  64299. /*** Helpers ***/
  64300. private _prepareSphere;
  64301. private _intersectsWithSphere;
  64302. }
  64303. /**
  64304. * Represents a gravitational field event
  64305. */
  64306. class PhysicsGravitationalFieldEvent {
  64307. private _physicsHelper;
  64308. private _scene;
  64309. private _origin;
  64310. private _options;
  64311. private _tickCallback;
  64312. private _sphere;
  64313. private _dataFetched;
  64314. /**
  64315. * Initializes the physics gravitational field event
  64316. * @param _physicsHelper A physics helper
  64317. * @param _scene BabylonJS scene
  64318. * @param _origin The origin position of the gravitational field event
  64319. * @param _options The options for the vortex event
  64320. */
  64321. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64322. /**
  64323. * Returns the data related to the gravitational field event (sphere).
  64324. * @returns A gravitational field event
  64325. */
  64326. getData(): PhysicsGravitationalFieldEventData;
  64327. /**
  64328. * Enables the gravitational field.
  64329. */
  64330. enable(): void;
  64331. /**
  64332. * Disables the gravitational field.
  64333. */
  64334. disable(): void;
  64335. /**
  64336. * Disposes the sphere.
  64337. * @param force The force to dispose from the gravitational field event
  64338. */
  64339. dispose(force?: boolean): void;
  64340. private _tick;
  64341. }
  64342. /**
  64343. * Represents a physics updraft event
  64344. */
  64345. class PhysicsUpdraftEvent {
  64346. private _scene;
  64347. private _origin;
  64348. private _options;
  64349. private _physicsEngine;
  64350. private _originTop;
  64351. private _originDirection;
  64352. private _tickCallback;
  64353. private _cylinder;
  64354. private _cylinderPosition;
  64355. private _dataFetched;
  64356. /**
  64357. * Initializes the physics updraft event
  64358. * @param _scene BabylonJS scene
  64359. * @param _origin The origin position of the updraft
  64360. * @param _options The options for the updraft event
  64361. */
  64362. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64363. /**
  64364. * Returns the data related to the updraft event (cylinder).
  64365. * @returns A physics updraft event
  64366. */
  64367. getData(): PhysicsUpdraftEventData;
  64368. /**
  64369. * Enables the updraft.
  64370. */
  64371. enable(): void;
  64372. /**
  64373. * Disables the updraft.
  64374. */
  64375. disable(): void;
  64376. /**
  64377. * Disposes the cylinder.
  64378. * @param force Specifies if the updraft should be disposed by force
  64379. */
  64380. dispose(force?: boolean): void;
  64381. private getImpostorHitData;
  64382. private _tick;
  64383. /*** Helpers ***/
  64384. private _prepareCylinder;
  64385. private _intersectsWithCylinder;
  64386. }
  64387. /**
  64388. * Represents a physics vortex event
  64389. */
  64390. class PhysicsVortexEvent {
  64391. private _scene;
  64392. private _origin;
  64393. private _options;
  64394. private _physicsEngine;
  64395. private _originTop;
  64396. private _tickCallback;
  64397. private _cylinder;
  64398. private _cylinderPosition;
  64399. private _dataFetched;
  64400. /**
  64401. * Initializes the physics vortex event
  64402. * @param _scene The BabylonJS scene
  64403. * @param _origin The origin position of the vortex
  64404. * @param _options The options for the vortex event
  64405. */
  64406. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64407. /**
  64408. * Returns the data related to the vortex event (cylinder).
  64409. * @returns The physics vortex event data
  64410. */
  64411. getData(): PhysicsVortexEventData;
  64412. /**
  64413. * Enables the vortex.
  64414. */
  64415. enable(): void;
  64416. /**
  64417. * Disables the cortex.
  64418. */
  64419. disable(): void;
  64420. /**
  64421. * Disposes the sphere.
  64422. * @param force
  64423. */
  64424. dispose(force?: boolean): void;
  64425. private getImpostorHitData;
  64426. private _tick;
  64427. /*** Helpers ***/
  64428. private _prepareCylinder;
  64429. private _intersectsWithCylinder;
  64430. }
  64431. /**
  64432. * Options fot the radial explosion event
  64433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64434. */
  64435. export class PhysicsRadialExplosionEventOptions {
  64436. /**
  64437. * The radius of the sphere for the radial explosion.
  64438. */
  64439. radius: number;
  64440. /**
  64441. * The strenth of the explosion.
  64442. */
  64443. strength: number;
  64444. /**
  64445. * The strenght of the force in correspondence to the distance of the affected object
  64446. */
  64447. falloff: PhysicsRadialImpulseFalloff;
  64448. /**
  64449. * Sphere options for the radial explosion.
  64450. */
  64451. sphere: {
  64452. segments: number;
  64453. diameter: number;
  64454. };
  64455. /**
  64456. * Sphere options for the radial explosion.
  64457. */
  64458. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64459. }
  64460. /**
  64461. * Options fot the updraft event
  64462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64463. */
  64464. export class PhysicsUpdraftEventOptions {
  64465. /**
  64466. * The radius of the cylinder for the vortex
  64467. */
  64468. radius: number;
  64469. /**
  64470. * The strenth of the updraft.
  64471. */
  64472. strength: number;
  64473. /**
  64474. * The height of the cylinder for the updraft.
  64475. */
  64476. height: number;
  64477. /**
  64478. * The mode for the the updraft.
  64479. */
  64480. updraftMode: PhysicsUpdraftMode;
  64481. }
  64482. /**
  64483. * Options fot the vortex event
  64484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64485. */
  64486. export class PhysicsVortexEventOptions {
  64487. /**
  64488. * The radius of the cylinder for the vortex
  64489. */
  64490. radius: number;
  64491. /**
  64492. * The strenth of the vortex.
  64493. */
  64494. strength: number;
  64495. /**
  64496. * The height of the cylinder for the vortex.
  64497. */
  64498. height: number;
  64499. /**
  64500. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64501. */
  64502. centripetalForceThreshold: number;
  64503. /**
  64504. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64505. */
  64506. centripetalForceMultiplier: number;
  64507. /**
  64508. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64509. */
  64510. centrifugalForceMultiplier: number;
  64511. /**
  64512. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64513. */
  64514. updraftForceMultiplier: number;
  64515. }
  64516. /**
  64517. * The strenght of the force in correspondence to the distance of the affected object
  64518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64519. */
  64520. export enum PhysicsRadialImpulseFalloff {
  64521. /** Defines that impulse is constant in strength across it's whole radius */
  64522. Constant = 0,
  64523. /** Defines that impulse gets weaker if it's further from the origin */
  64524. Linear = 1
  64525. }
  64526. /**
  64527. * The strength of the force in correspondence to the distance of the affected object
  64528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64529. */
  64530. export enum PhysicsUpdraftMode {
  64531. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64532. Center = 0,
  64533. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64534. Perpendicular = 1
  64535. }
  64536. /**
  64537. * Interface for a physics hit data
  64538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64539. */
  64540. export interface PhysicsHitData {
  64541. /**
  64542. * The force applied at the contact point
  64543. */
  64544. force: Vector3;
  64545. /**
  64546. * The contact point
  64547. */
  64548. contactPoint: Vector3;
  64549. /**
  64550. * The distance from the origin to the contact point
  64551. */
  64552. distanceFromOrigin: number;
  64553. }
  64554. /**
  64555. * Interface for radial explosion event data
  64556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64557. */
  64558. export interface PhysicsRadialExplosionEventData {
  64559. /**
  64560. * A sphere used for the radial explosion event
  64561. */
  64562. sphere: Mesh;
  64563. }
  64564. /**
  64565. * Interface for gravitational field event data
  64566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64567. */
  64568. export interface PhysicsGravitationalFieldEventData {
  64569. /**
  64570. * A sphere mesh used for the gravitational field event
  64571. */
  64572. sphere: Mesh;
  64573. }
  64574. /**
  64575. * Interface for updraft event data
  64576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64577. */
  64578. export interface PhysicsUpdraftEventData {
  64579. /**
  64580. * A cylinder used for the updraft event
  64581. */
  64582. cylinder: Mesh;
  64583. }
  64584. /**
  64585. * Interface for vortex event data
  64586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64587. */
  64588. export interface PhysicsVortexEventData {
  64589. /**
  64590. * A cylinder used for the vortex event
  64591. */
  64592. cylinder: Mesh;
  64593. }
  64594. /**
  64595. * Interface for an affected physics impostor
  64596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64597. */
  64598. export interface PhysicsAffectedImpostorWithData {
  64599. /**
  64600. * The impostor affected by the effect
  64601. */
  64602. impostor: PhysicsImpostor;
  64603. /**
  64604. * The data about the hit/horce from the explosion
  64605. */
  64606. hitData: PhysicsHitData;
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /** @hidden */
  64611. export var blackAndWhitePixelShader: {
  64612. name: string;
  64613. shader: string;
  64614. };
  64615. }
  64616. declare module BABYLON {
  64617. /**
  64618. * Post process used to render in black and white
  64619. */
  64620. export class BlackAndWhitePostProcess extends PostProcess {
  64621. /**
  64622. * Linear about to convert he result to black and white (default: 1)
  64623. */
  64624. degree: number;
  64625. /**
  64626. * Creates a black and white post process
  64627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64628. * @param name The name of the effect.
  64629. * @param options The required width/height ratio to downsize to before computing the render pass.
  64630. * @param camera The camera to apply the render pass to.
  64631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64632. * @param engine The engine which the post process will be applied. (default: current engine)
  64633. * @param reusable If the post process can be reused on the same frame. (default: false)
  64634. */
  64635. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64636. }
  64637. }
  64638. declare module BABYLON {
  64639. /**
  64640. * This represents a set of one or more post processes in Babylon.
  64641. * A post process can be used to apply a shader to a texture after it is rendered.
  64642. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64643. */
  64644. export class PostProcessRenderEffect {
  64645. private _postProcesses;
  64646. private _getPostProcesses;
  64647. private _singleInstance;
  64648. private _cameras;
  64649. private _indicesForCamera;
  64650. /**
  64651. * Name of the effect
  64652. * @hidden
  64653. */
  64654. _name: string;
  64655. /**
  64656. * Instantiates a post process render effect.
  64657. * A post process can be used to apply a shader to a texture after it is rendered.
  64658. * @param engine The engine the effect is tied to
  64659. * @param name The name of the effect
  64660. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64661. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64662. */
  64663. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64664. /**
  64665. * Checks if all the post processes in the effect are supported.
  64666. */
  64667. get isSupported(): boolean;
  64668. /**
  64669. * Updates the current state of the effect
  64670. * @hidden
  64671. */
  64672. _update(): void;
  64673. /**
  64674. * Attaches the effect on cameras
  64675. * @param cameras The camera to attach to.
  64676. * @hidden
  64677. */
  64678. _attachCameras(cameras: Camera): void;
  64679. /**
  64680. * Attaches the effect on cameras
  64681. * @param cameras The camera to attach to.
  64682. * @hidden
  64683. */
  64684. _attachCameras(cameras: Camera[]): void;
  64685. /**
  64686. * Detaches the effect on cameras
  64687. * @param cameras The camera to detatch from.
  64688. * @hidden
  64689. */
  64690. _detachCameras(cameras: Camera): void;
  64691. /**
  64692. * Detatches the effect on cameras
  64693. * @param cameras The camera to detatch from.
  64694. * @hidden
  64695. */
  64696. _detachCameras(cameras: Camera[]): void;
  64697. /**
  64698. * Enables the effect on given cameras
  64699. * @param cameras The camera to enable.
  64700. * @hidden
  64701. */
  64702. _enable(cameras: Camera): void;
  64703. /**
  64704. * Enables the effect on given cameras
  64705. * @param cameras The camera to enable.
  64706. * @hidden
  64707. */
  64708. _enable(cameras: Nullable<Camera[]>): void;
  64709. /**
  64710. * Disables the effect on the given cameras
  64711. * @param cameras The camera to disable.
  64712. * @hidden
  64713. */
  64714. _disable(cameras: Camera): void;
  64715. /**
  64716. * Disables the effect on the given cameras
  64717. * @param cameras The camera to disable.
  64718. * @hidden
  64719. */
  64720. _disable(cameras: Nullable<Camera[]>): void;
  64721. /**
  64722. * Gets a list of the post processes contained in the effect.
  64723. * @param camera The camera to get the post processes on.
  64724. * @returns The list of the post processes in the effect.
  64725. */
  64726. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /** @hidden */
  64731. export var extractHighlightsPixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module BABYLON {
  64737. /**
  64738. * 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.
  64739. */
  64740. export class ExtractHighlightsPostProcess extends PostProcess {
  64741. /**
  64742. * The luminance threshold, pixels below this value will be set to black.
  64743. */
  64744. threshold: number;
  64745. /** @hidden */
  64746. _exposure: number;
  64747. /**
  64748. * Post process which has the input texture to be used when performing highlight extraction
  64749. * @hidden
  64750. */
  64751. _inputPostProcess: Nullable<PostProcess>;
  64752. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64753. }
  64754. }
  64755. declare module BABYLON {
  64756. /** @hidden */
  64757. export var bloomMergePixelShader: {
  64758. name: string;
  64759. shader: string;
  64760. };
  64761. }
  64762. declare module BABYLON {
  64763. /**
  64764. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64765. */
  64766. export class BloomMergePostProcess extends PostProcess {
  64767. /** Weight of the bloom to be added to the original input. */
  64768. weight: number;
  64769. /**
  64770. * Creates a new instance of @see BloomMergePostProcess
  64771. * @param name The name of the effect.
  64772. * @param originalFromInput Post process which's input will be used for the merge.
  64773. * @param blurred Blurred highlights post process which's output will be used.
  64774. * @param weight Weight of the bloom to be added to the original input.
  64775. * @param options The required width/height ratio to downsize to before computing the render pass.
  64776. * @param camera The camera to apply the render pass to.
  64777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64778. * @param engine The engine which the post process will be applied. (default: current engine)
  64779. * @param reusable If the post process can be reused on the same frame. (default: false)
  64780. * @param textureType Type of textures used when performing the post process. (default: 0)
  64781. * @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)
  64782. */
  64783. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64784. /** Weight of the bloom to be added to the original input. */
  64785. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64786. }
  64787. }
  64788. declare module BABYLON {
  64789. /**
  64790. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64791. */
  64792. export class BloomEffect extends PostProcessRenderEffect {
  64793. private bloomScale;
  64794. /**
  64795. * @hidden Internal
  64796. */
  64797. _effects: Array<PostProcess>;
  64798. /**
  64799. * @hidden Internal
  64800. */
  64801. _downscale: ExtractHighlightsPostProcess;
  64802. private _blurX;
  64803. private _blurY;
  64804. private _merge;
  64805. /**
  64806. * The luminance threshold to find bright areas of the image to bloom.
  64807. */
  64808. get threshold(): number;
  64809. set threshold(value: number);
  64810. /**
  64811. * The strength of the bloom.
  64812. */
  64813. get weight(): number;
  64814. set weight(value: number);
  64815. /**
  64816. * Specifies the size of the bloom blur kernel, relative to the final output size
  64817. */
  64818. get kernel(): number;
  64819. set kernel(value: number);
  64820. /**
  64821. * Creates a new instance of @see BloomEffect
  64822. * @param scene The scene the effect belongs to.
  64823. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64824. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64825. * @param bloomWeight The the strength of bloom.
  64826. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64827. * @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)
  64828. */
  64829. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64830. /**
  64831. * Disposes each of the internal effects for a given camera.
  64832. * @param camera The camera to dispose the effect on.
  64833. */
  64834. disposeEffects(camera: Camera): void;
  64835. /**
  64836. * @hidden Internal
  64837. */
  64838. _updateEffects(): void;
  64839. /**
  64840. * Internal
  64841. * @returns if all the contained post processes are ready.
  64842. * @hidden
  64843. */
  64844. _isReady(): boolean;
  64845. }
  64846. }
  64847. declare module BABYLON {
  64848. /** @hidden */
  64849. export var chromaticAberrationPixelShader: {
  64850. name: string;
  64851. shader: string;
  64852. };
  64853. }
  64854. declare module BABYLON {
  64855. /**
  64856. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64857. */
  64858. export class ChromaticAberrationPostProcess extends PostProcess {
  64859. /**
  64860. * The amount of seperation of rgb channels (default: 30)
  64861. */
  64862. aberrationAmount: number;
  64863. /**
  64864. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64865. */
  64866. radialIntensity: number;
  64867. /**
  64868. * 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))
  64869. */
  64870. direction: Vector2;
  64871. /**
  64872. * 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))
  64873. */
  64874. centerPosition: Vector2;
  64875. /**
  64876. * Creates a new instance ChromaticAberrationPostProcess
  64877. * @param name The name of the effect.
  64878. * @param screenWidth The width of the screen to apply the effect on.
  64879. * @param screenHeight The height of the screen to apply the effect on.
  64880. * @param options The required width/height ratio to downsize to before computing the render pass.
  64881. * @param camera The camera to apply the render pass to.
  64882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64883. * @param engine The engine which the post process will be applied. (default: current engine)
  64884. * @param reusable If the post process can be reused on the same frame. (default: false)
  64885. * @param textureType Type of textures used when performing the post process. (default: 0)
  64886. * @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)
  64887. */
  64888. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /** @hidden */
  64893. export var circleOfConfusionPixelShader: {
  64894. name: string;
  64895. shader: string;
  64896. };
  64897. }
  64898. declare module BABYLON {
  64899. /**
  64900. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64901. */
  64902. export class CircleOfConfusionPostProcess extends PostProcess {
  64903. /**
  64904. * 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.
  64905. */
  64906. lensSize: number;
  64907. /**
  64908. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64909. */
  64910. fStop: number;
  64911. /**
  64912. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64913. */
  64914. focusDistance: number;
  64915. /**
  64916. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64917. */
  64918. focalLength: number;
  64919. private _depthTexture;
  64920. /**
  64921. * Creates a new instance CircleOfConfusionPostProcess
  64922. * @param name The name of the effect.
  64923. * @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.
  64924. * @param options The required width/height ratio to downsize to before computing the render pass.
  64925. * @param camera The camera to apply the render pass to.
  64926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64927. * @param engine The engine which the post process will be applied. (default: current engine)
  64928. * @param reusable If the post process can be reused on the same frame. (default: false)
  64929. * @param textureType Type of textures used when performing the post process. (default: 0)
  64930. * @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)
  64931. */
  64932. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64933. /**
  64934. * 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.
  64935. */
  64936. set depthTexture(value: RenderTargetTexture);
  64937. }
  64938. }
  64939. declare module BABYLON {
  64940. /** @hidden */
  64941. export var colorCorrectionPixelShader: {
  64942. name: string;
  64943. shader: string;
  64944. };
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. *
  64949. * This post-process allows the modification of rendered colors by using
  64950. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64951. *
  64952. * The object needs to be provided an url to a texture containing the color
  64953. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64954. * Use an image editing software to tweak the LUT to match your needs.
  64955. *
  64956. * For an example of a color LUT, see here:
  64957. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64958. * For explanations on color grading, see here:
  64959. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64960. *
  64961. */
  64962. export class ColorCorrectionPostProcess extends PostProcess {
  64963. private _colorTableTexture;
  64964. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64965. }
  64966. }
  64967. declare module BABYLON {
  64968. /** @hidden */
  64969. export var convolutionPixelShader: {
  64970. name: string;
  64971. shader: string;
  64972. };
  64973. }
  64974. declare module BABYLON {
  64975. /**
  64976. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64977. * input texture to perform effects such as edge detection or sharpening
  64978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64979. */
  64980. export class ConvolutionPostProcess extends PostProcess {
  64981. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64982. kernel: number[];
  64983. /**
  64984. * Creates a new instance ConvolutionPostProcess
  64985. * @param name The name of the effect.
  64986. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64987. * @param options The required width/height ratio to downsize to before computing the render pass.
  64988. * @param camera The camera to apply the render pass to.
  64989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64990. * @param engine The engine which the post process will be applied. (default: current engine)
  64991. * @param reusable If the post process can be reused on the same frame. (default: false)
  64992. * @param textureType Type of textures used when performing the post process. (default: 0)
  64993. */
  64994. constructor(name: string,
  64995. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64996. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64997. /**
  64998. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64999. */
  65000. static EdgeDetect0Kernel: number[];
  65001. /**
  65002. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65003. */
  65004. static EdgeDetect1Kernel: number[];
  65005. /**
  65006. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65007. */
  65008. static EdgeDetect2Kernel: number[];
  65009. /**
  65010. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65011. */
  65012. static SharpenKernel: number[];
  65013. /**
  65014. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65015. */
  65016. static EmbossKernel: number[];
  65017. /**
  65018. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65019. */
  65020. static GaussianKernel: number[];
  65021. }
  65022. }
  65023. declare module BABYLON {
  65024. /**
  65025. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65026. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65027. * based on samples that have a large difference in distance than the center pixel.
  65028. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65029. */
  65030. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65031. direction: Vector2;
  65032. /**
  65033. * Creates a new instance CircleOfConfusionPostProcess
  65034. * @param name The name of the effect.
  65035. * @param scene The scene the effect belongs to.
  65036. * @param direction The direction the blur should be applied.
  65037. * @param kernel The size of the kernel used to blur.
  65038. * @param options The required width/height ratio to downsize to before computing the render pass.
  65039. * @param camera The camera to apply the render pass to.
  65040. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65041. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65043. * @param engine The engine which the post process will be applied. (default: current engine)
  65044. * @param reusable If the post process can be reused on the same frame. (default: false)
  65045. * @param textureType Type of textures used when performing the post process. (default: 0)
  65046. * @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)
  65047. */
  65048. 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);
  65049. }
  65050. }
  65051. declare module BABYLON {
  65052. /** @hidden */
  65053. export var depthOfFieldMergePixelShader: {
  65054. name: string;
  65055. shader: string;
  65056. };
  65057. }
  65058. declare module BABYLON {
  65059. /**
  65060. * Options to be set when merging outputs from the default pipeline.
  65061. */
  65062. export class DepthOfFieldMergePostProcessOptions {
  65063. /**
  65064. * The original image to merge on top of
  65065. */
  65066. originalFromInput: PostProcess;
  65067. /**
  65068. * Parameters to perform the merge of the depth of field effect
  65069. */
  65070. depthOfField?: {
  65071. circleOfConfusion: PostProcess;
  65072. blurSteps: Array<PostProcess>;
  65073. };
  65074. /**
  65075. * Parameters to perform the merge of bloom effect
  65076. */
  65077. bloom?: {
  65078. blurred: PostProcess;
  65079. weight: number;
  65080. };
  65081. }
  65082. /**
  65083. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65084. */
  65085. export class DepthOfFieldMergePostProcess extends PostProcess {
  65086. private blurSteps;
  65087. /**
  65088. * Creates a new instance of DepthOfFieldMergePostProcess
  65089. * @param name The name of the effect.
  65090. * @param originalFromInput Post process which's input will be used for the merge.
  65091. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65092. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65093. * @param options The required width/height ratio to downsize to before computing the render pass.
  65094. * @param camera The camera to apply the render pass to.
  65095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65096. * @param engine The engine which the post process will be applied. (default: current engine)
  65097. * @param reusable If the post process can be reused on the same frame. (default: false)
  65098. * @param textureType Type of textures used when performing the post process. (default: 0)
  65099. * @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)
  65100. */
  65101. 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);
  65102. /**
  65103. * Updates the effect with the current post process compile time values and recompiles the shader.
  65104. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65105. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65106. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65107. * @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
  65108. * @param onCompiled Called when the shader has been compiled.
  65109. * @param onError Called if there is an error when compiling a shader.
  65110. */
  65111. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Specifies the level of max blur that should be applied when using the depth of field effect
  65117. */
  65118. export enum DepthOfFieldEffectBlurLevel {
  65119. /**
  65120. * Subtle blur
  65121. */
  65122. Low = 0,
  65123. /**
  65124. * Medium blur
  65125. */
  65126. Medium = 1,
  65127. /**
  65128. * Large blur
  65129. */
  65130. High = 2
  65131. }
  65132. /**
  65133. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65134. */
  65135. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65136. private _circleOfConfusion;
  65137. /**
  65138. * @hidden Internal, blurs from high to low
  65139. */
  65140. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65141. private _depthOfFieldBlurY;
  65142. private _dofMerge;
  65143. /**
  65144. * @hidden Internal post processes in depth of field effect
  65145. */
  65146. _effects: Array<PostProcess>;
  65147. /**
  65148. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65149. */
  65150. set focalLength(value: number);
  65151. get focalLength(): number;
  65152. /**
  65153. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65154. */
  65155. set fStop(value: number);
  65156. get fStop(): number;
  65157. /**
  65158. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65159. */
  65160. set focusDistance(value: number);
  65161. get focusDistance(): number;
  65162. /**
  65163. * 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.
  65164. */
  65165. set lensSize(value: number);
  65166. get lensSize(): number;
  65167. /**
  65168. * Creates a new instance DepthOfFieldEffect
  65169. * @param scene The scene the effect belongs to.
  65170. * @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.
  65171. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65172. * @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)
  65173. */
  65174. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65175. /**
  65176. * Get the current class name of the current effet
  65177. * @returns "DepthOfFieldEffect"
  65178. */
  65179. getClassName(): string;
  65180. /**
  65181. * 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.
  65182. */
  65183. set depthTexture(value: RenderTargetTexture);
  65184. /**
  65185. * Disposes each of the internal effects for a given camera.
  65186. * @param camera The camera to dispose the effect on.
  65187. */
  65188. disposeEffects(camera: Camera): void;
  65189. /**
  65190. * @hidden Internal
  65191. */
  65192. _updateEffects(): void;
  65193. /**
  65194. * Internal
  65195. * @returns if all the contained post processes are ready.
  65196. * @hidden
  65197. */
  65198. _isReady(): boolean;
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /** @hidden */
  65203. export var displayPassPixelShader: {
  65204. name: string;
  65205. shader: string;
  65206. };
  65207. }
  65208. declare module BABYLON {
  65209. /**
  65210. * DisplayPassPostProcess which produces an output the same as it's input
  65211. */
  65212. export class DisplayPassPostProcess extends PostProcess {
  65213. /**
  65214. * Creates the DisplayPassPostProcess
  65215. * @param name The name of the effect.
  65216. * @param options The required width/height ratio to downsize to before computing the render pass.
  65217. * @param camera The camera to apply the render pass to.
  65218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65219. * @param engine The engine which the post process will be applied. (default: current engine)
  65220. * @param reusable If the post process can be reused on the same frame. (default: false)
  65221. */
  65222. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65223. }
  65224. }
  65225. declare module BABYLON {
  65226. /** @hidden */
  65227. export var filterPixelShader: {
  65228. name: string;
  65229. shader: string;
  65230. };
  65231. }
  65232. declare module BABYLON {
  65233. /**
  65234. * Applies a kernel filter to the image
  65235. */
  65236. export class FilterPostProcess extends PostProcess {
  65237. /** The matrix to be applied to the image */
  65238. kernelMatrix: Matrix;
  65239. /**
  65240. *
  65241. * @param name The name of the effect.
  65242. * @param kernelMatrix The matrix to be applied to the image
  65243. * @param options The required width/height ratio to downsize to before computing the render pass.
  65244. * @param camera The camera to apply the render pass to.
  65245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65246. * @param engine The engine which the post process will be applied. (default: current engine)
  65247. * @param reusable If the post process can be reused on the same frame. (default: false)
  65248. */
  65249. constructor(name: string,
  65250. /** The matrix to be applied to the image */
  65251. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65252. }
  65253. }
  65254. declare module BABYLON {
  65255. /** @hidden */
  65256. export var fxaaPixelShader: {
  65257. name: string;
  65258. shader: string;
  65259. };
  65260. }
  65261. declare module BABYLON {
  65262. /** @hidden */
  65263. export var fxaaVertexShader: {
  65264. name: string;
  65265. shader: string;
  65266. };
  65267. }
  65268. declare module BABYLON {
  65269. /**
  65270. * Fxaa post process
  65271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65272. */
  65273. export class FxaaPostProcess extends PostProcess {
  65274. /** @hidden */
  65275. texelWidth: number;
  65276. /** @hidden */
  65277. texelHeight: number;
  65278. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65279. private _getDefines;
  65280. }
  65281. }
  65282. declare module BABYLON {
  65283. /** @hidden */
  65284. export var grainPixelShader: {
  65285. name: string;
  65286. shader: string;
  65287. };
  65288. }
  65289. declare module BABYLON {
  65290. /**
  65291. * The GrainPostProcess adds noise to the image at mid luminance levels
  65292. */
  65293. export class GrainPostProcess extends PostProcess {
  65294. /**
  65295. * The intensity of the grain added (default: 30)
  65296. */
  65297. intensity: number;
  65298. /**
  65299. * If the grain should be randomized on every frame
  65300. */
  65301. animated: boolean;
  65302. /**
  65303. * Creates a new instance of @see GrainPostProcess
  65304. * @param name The name of the effect.
  65305. * @param options The required width/height ratio to downsize to before computing the render pass.
  65306. * @param camera The camera to apply the render pass to.
  65307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65308. * @param engine The engine which the post process will be applied. (default: current engine)
  65309. * @param reusable If the post process can be reused on the same frame. (default: false)
  65310. * @param textureType Type of textures used when performing the post process. (default: 0)
  65311. * @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)
  65312. */
  65313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65314. }
  65315. }
  65316. declare module BABYLON {
  65317. /** @hidden */
  65318. export var highlightsPixelShader: {
  65319. name: string;
  65320. shader: string;
  65321. };
  65322. }
  65323. declare module BABYLON {
  65324. /**
  65325. * Extracts highlights from the image
  65326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65327. */
  65328. export class HighlightsPostProcess extends PostProcess {
  65329. /**
  65330. * Extracts highlights from the image
  65331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65332. * @param name The name of the effect.
  65333. * @param options The required width/height ratio to downsize to before computing the render pass.
  65334. * @param camera The camera to apply the render pass to.
  65335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65336. * @param engine The engine which the post process will be applied. (default: current engine)
  65337. * @param reusable If the post process can be reused on the same frame. (default: false)
  65338. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65339. */
  65340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65341. }
  65342. }
  65343. declare module BABYLON {
  65344. /** @hidden */
  65345. export var mrtFragmentDeclaration: {
  65346. name: string;
  65347. shader: string;
  65348. };
  65349. }
  65350. declare module BABYLON {
  65351. /** @hidden */
  65352. export var geometryPixelShader: {
  65353. name: string;
  65354. shader: string;
  65355. };
  65356. }
  65357. declare module BABYLON {
  65358. /** @hidden */
  65359. export var geometryVertexShader: {
  65360. name: string;
  65361. shader: string;
  65362. };
  65363. }
  65364. declare module BABYLON {
  65365. /** @hidden */
  65366. interface ISavedTransformationMatrix {
  65367. world: Matrix;
  65368. viewProjection: Matrix;
  65369. }
  65370. /**
  65371. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65372. */
  65373. export class GeometryBufferRenderer {
  65374. /**
  65375. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65376. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65377. */
  65378. static readonly POSITION_TEXTURE_TYPE: number;
  65379. /**
  65380. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65381. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65382. */
  65383. static readonly VELOCITY_TEXTURE_TYPE: number;
  65384. /**
  65385. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65386. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65387. */
  65388. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65389. /**
  65390. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65391. * in order to compute objects velocities when enableVelocity is set to "true"
  65392. * @hidden
  65393. */
  65394. _previousTransformationMatrices: {
  65395. [index: number]: ISavedTransformationMatrix;
  65396. };
  65397. /**
  65398. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65399. * in order to compute objects velocities when enableVelocity is set to "true"
  65400. * @hidden
  65401. */
  65402. _previousBonesTransformationMatrices: {
  65403. [index: number]: Float32Array;
  65404. };
  65405. /**
  65406. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65407. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65408. */
  65409. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65410. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65411. renderTransparentMeshes: boolean;
  65412. private _scene;
  65413. private _multiRenderTarget;
  65414. private _ratio;
  65415. private _enablePosition;
  65416. private _enableVelocity;
  65417. private _enableReflectivity;
  65418. private _positionIndex;
  65419. private _velocityIndex;
  65420. private _reflectivityIndex;
  65421. protected _effect: Effect;
  65422. protected _cachedDefines: string;
  65423. /**
  65424. * Set the render list (meshes to be rendered) used in the G buffer.
  65425. */
  65426. set renderList(meshes: Mesh[]);
  65427. /**
  65428. * Gets wether or not G buffer are supported by the running hardware.
  65429. * This requires draw buffer supports
  65430. */
  65431. get isSupported(): boolean;
  65432. /**
  65433. * Returns the index of the given texture type in the G-Buffer textures array
  65434. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65435. * @returns the index of the given texture type in the G-Buffer textures array
  65436. */
  65437. getTextureIndex(textureType: number): number;
  65438. /**
  65439. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65440. */
  65441. get enablePosition(): boolean;
  65442. /**
  65443. * Sets whether or not objects positions are enabled for the G buffer.
  65444. */
  65445. set enablePosition(enable: boolean);
  65446. /**
  65447. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65448. */
  65449. get enableVelocity(): boolean;
  65450. /**
  65451. * Sets wether or not objects velocities are enabled for the G buffer.
  65452. */
  65453. set enableVelocity(enable: boolean);
  65454. /**
  65455. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65456. */
  65457. get enableReflectivity(): boolean;
  65458. /**
  65459. * Sets wether or not objects roughness are enabled for the G buffer.
  65460. */
  65461. set enableReflectivity(enable: boolean);
  65462. /**
  65463. * Gets the scene associated with the buffer.
  65464. */
  65465. get scene(): Scene;
  65466. /**
  65467. * Gets the ratio used by the buffer during its creation.
  65468. * How big is the buffer related to the main canvas.
  65469. */
  65470. get ratio(): number;
  65471. /** @hidden */
  65472. static _SceneComponentInitialization: (scene: Scene) => void;
  65473. /**
  65474. * Creates a new G Buffer for the scene
  65475. * @param scene The scene the buffer belongs to
  65476. * @param ratio How big is the buffer related to the main canvas.
  65477. */
  65478. constructor(scene: Scene, ratio?: number);
  65479. /**
  65480. * Checks wether everything is ready to render a submesh to the G buffer.
  65481. * @param subMesh the submesh to check readiness for
  65482. * @param useInstances is the mesh drawn using instance or not
  65483. * @returns true if ready otherwise false
  65484. */
  65485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65486. /**
  65487. * Gets the current underlying G Buffer.
  65488. * @returns the buffer
  65489. */
  65490. getGBuffer(): MultiRenderTarget;
  65491. /**
  65492. * Gets the number of samples used to render the buffer (anti aliasing).
  65493. */
  65494. get samples(): number;
  65495. /**
  65496. * Sets the number of samples used to render the buffer (anti aliasing).
  65497. */
  65498. set samples(value: number);
  65499. /**
  65500. * Disposes the renderer and frees up associated resources.
  65501. */
  65502. dispose(): void;
  65503. protected _createRenderTargets(): void;
  65504. private _copyBonesTransformationMatrices;
  65505. }
  65506. }
  65507. declare module BABYLON {
  65508. interface Scene {
  65509. /** @hidden (Backing field) */
  65510. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65511. /**
  65512. * Gets or Sets the current geometry buffer associated to the scene.
  65513. */
  65514. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65515. /**
  65516. * Enables a GeometryBufferRender and associates it with the scene
  65517. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65518. * @returns the GeometryBufferRenderer
  65519. */
  65520. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65521. /**
  65522. * Disables the GeometryBufferRender associated with the scene
  65523. */
  65524. disableGeometryBufferRenderer(): void;
  65525. }
  65526. /**
  65527. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65528. * in several rendering techniques.
  65529. */
  65530. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65531. /**
  65532. * The component name helpful to identify the component in the list of scene components.
  65533. */
  65534. readonly name: string;
  65535. /**
  65536. * The scene the component belongs to.
  65537. */
  65538. scene: Scene;
  65539. /**
  65540. * Creates a new instance of the component for the given scene
  65541. * @param scene Defines the scene to register the component in
  65542. */
  65543. constructor(scene: Scene);
  65544. /**
  65545. * Registers the component in a given scene
  65546. */
  65547. register(): void;
  65548. /**
  65549. * Rebuilds the elements related to this component in case of
  65550. * context lost for instance.
  65551. */
  65552. rebuild(): void;
  65553. /**
  65554. * Disposes the component and the associated ressources
  65555. */
  65556. dispose(): void;
  65557. private _gatherRenderTargets;
  65558. }
  65559. }
  65560. declare module BABYLON {
  65561. /** @hidden */
  65562. export var motionBlurPixelShader: {
  65563. name: string;
  65564. shader: string;
  65565. };
  65566. }
  65567. declare module BABYLON {
  65568. /**
  65569. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65570. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65571. * As an example, all you have to do is to create the post-process:
  65572. * var mb = new BABYLON.MotionBlurPostProcess(
  65573. * 'mb', // The name of the effect.
  65574. * scene, // The scene containing the objects to blur according to their velocity.
  65575. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65576. * camera // The camera to apply the render pass to.
  65577. * );
  65578. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65579. */
  65580. export class MotionBlurPostProcess extends PostProcess {
  65581. /**
  65582. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65583. */
  65584. motionStrength: number;
  65585. /**
  65586. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65587. */
  65588. get motionBlurSamples(): number;
  65589. /**
  65590. * Sets the number of iterations to be used for motion blur quality
  65591. */
  65592. set motionBlurSamples(samples: number);
  65593. private _motionBlurSamples;
  65594. private _geometryBufferRenderer;
  65595. /**
  65596. * Creates a new instance MotionBlurPostProcess
  65597. * @param name The name of the effect.
  65598. * @param scene The scene containing the objects to blur according to their velocity.
  65599. * @param options The required width/height ratio to downsize to before computing the render pass.
  65600. * @param camera The camera to apply the render pass to.
  65601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65602. * @param engine The engine which the post process will be applied. (default: current engine)
  65603. * @param reusable If the post process can be reused on the same frame. (default: false)
  65604. * @param textureType Type of textures used when performing the post process. (default: 0)
  65605. * @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)
  65606. */
  65607. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65608. /**
  65609. * Excludes the given skinned mesh from computing bones velocities.
  65610. * 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.
  65611. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65612. */
  65613. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65614. /**
  65615. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65616. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65617. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65618. */
  65619. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65620. /**
  65621. * Disposes the post process.
  65622. * @param camera The camera to dispose the post process on.
  65623. */
  65624. dispose(camera?: Camera): void;
  65625. }
  65626. }
  65627. declare module BABYLON {
  65628. /** @hidden */
  65629. export var refractionPixelShader: {
  65630. name: string;
  65631. shader: string;
  65632. };
  65633. }
  65634. declare module BABYLON {
  65635. /**
  65636. * Post process which applies a refractin texture
  65637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65638. */
  65639. export class RefractionPostProcess extends PostProcess {
  65640. /** the base color of the refraction (used to taint the rendering) */
  65641. color: Color3;
  65642. /** simulated refraction depth */
  65643. depth: number;
  65644. /** the coefficient of the base color (0 to remove base color tainting) */
  65645. colorLevel: number;
  65646. private _refTexture;
  65647. private _ownRefractionTexture;
  65648. /**
  65649. * Gets or sets the refraction texture
  65650. * Please note that you are responsible for disposing the texture if you set it manually
  65651. */
  65652. get refractionTexture(): Texture;
  65653. set refractionTexture(value: Texture);
  65654. /**
  65655. * Initializes the RefractionPostProcess
  65656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65657. * @param name The name of the effect.
  65658. * @param refractionTextureUrl Url of the refraction texture to use
  65659. * @param color the base color of the refraction (used to taint the rendering)
  65660. * @param depth simulated refraction depth
  65661. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65662. * @param camera The camera to apply the render pass to.
  65663. * @param options The required width/height ratio to downsize to before computing the render pass.
  65664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65665. * @param engine The engine which the post process will be applied. (default: current engine)
  65666. * @param reusable If the post process can be reused on the same frame. (default: false)
  65667. */
  65668. constructor(name: string, refractionTextureUrl: string,
  65669. /** the base color of the refraction (used to taint the rendering) */
  65670. color: Color3,
  65671. /** simulated refraction depth */
  65672. depth: number,
  65673. /** the coefficient of the base color (0 to remove base color tainting) */
  65674. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65675. /**
  65676. * Disposes of the post process
  65677. * @param camera Camera to dispose post process on
  65678. */
  65679. dispose(camera: Camera): void;
  65680. }
  65681. }
  65682. declare module BABYLON {
  65683. /** @hidden */
  65684. export var sharpenPixelShader: {
  65685. name: string;
  65686. shader: string;
  65687. };
  65688. }
  65689. declare module BABYLON {
  65690. /**
  65691. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65692. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65693. */
  65694. export class SharpenPostProcess extends PostProcess {
  65695. /**
  65696. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65697. */
  65698. colorAmount: number;
  65699. /**
  65700. * How much sharpness should be applied (default: 0.3)
  65701. */
  65702. edgeAmount: number;
  65703. /**
  65704. * Creates a new instance ConvolutionPostProcess
  65705. * @param name The name of the effect.
  65706. * @param options The required width/height ratio to downsize to before computing the render pass.
  65707. * @param camera The camera to apply the render pass to.
  65708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65709. * @param engine The engine which the post process will be applied. (default: current engine)
  65710. * @param reusable If the post process can be reused on the same frame. (default: false)
  65711. * @param textureType Type of textures used when performing the post process. (default: 0)
  65712. * @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)
  65713. */
  65714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65715. }
  65716. }
  65717. declare module BABYLON {
  65718. /**
  65719. * PostProcessRenderPipeline
  65720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65721. */
  65722. export class PostProcessRenderPipeline {
  65723. private engine;
  65724. private _renderEffects;
  65725. private _renderEffectsForIsolatedPass;
  65726. /**
  65727. * List of inspectable custom properties (used by the Inspector)
  65728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65729. */
  65730. inspectableCustomProperties: IInspectable[];
  65731. /**
  65732. * @hidden
  65733. */
  65734. protected _cameras: Camera[];
  65735. /** @hidden */
  65736. _name: string;
  65737. /**
  65738. * Gets pipeline name
  65739. */
  65740. get name(): string;
  65741. /** Gets the list of attached cameras */
  65742. get cameras(): Camera[];
  65743. /**
  65744. * Initializes a PostProcessRenderPipeline
  65745. * @param engine engine to add the pipeline to
  65746. * @param name name of the pipeline
  65747. */
  65748. constructor(engine: Engine, name: string);
  65749. /**
  65750. * Gets the class name
  65751. * @returns "PostProcessRenderPipeline"
  65752. */
  65753. getClassName(): string;
  65754. /**
  65755. * If all the render effects in the pipeline are supported
  65756. */
  65757. get isSupported(): boolean;
  65758. /**
  65759. * Adds an effect to the pipeline
  65760. * @param renderEffect the effect to add
  65761. */
  65762. addEffect(renderEffect: PostProcessRenderEffect): void;
  65763. /** @hidden */
  65764. _rebuild(): void;
  65765. /** @hidden */
  65766. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65767. /** @hidden */
  65768. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65769. /** @hidden */
  65770. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65771. /** @hidden */
  65772. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65773. /** @hidden */
  65774. _attachCameras(cameras: Camera, unique: boolean): void;
  65775. /** @hidden */
  65776. _attachCameras(cameras: Camera[], unique: boolean): void;
  65777. /** @hidden */
  65778. _detachCameras(cameras: Camera): void;
  65779. /** @hidden */
  65780. _detachCameras(cameras: Nullable<Camera[]>): void;
  65781. /** @hidden */
  65782. _update(): void;
  65783. /** @hidden */
  65784. _reset(): void;
  65785. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65786. /**
  65787. * Disposes of the pipeline
  65788. */
  65789. dispose(): void;
  65790. }
  65791. }
  65792. declare module BABYLON {
  65793. /**
  65794. * PostProcessRenderPipelineManager class
  65795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65796. */
  65797. export class PostProcessRenderPipelineManager {
  65798. private _renderPipelines;
  65799. /**
  65800. * Initializes a PostProcessRenderPipelineManager
  65801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65802. */
  65803. constructor();
  65804. /**
  65805. * Gets the list of supported render pipelines
  65806. */
  65807. get supportedPipelines(): PostProcessRenderPipeline[];
  65808. /**
  65809. * Adds a pipeline to the manager
  65810. * @param renderPipeline The pipeline to add
  65811. */
  65812. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65813. /**
  65814. * Attaches a camera to the pipeline
  65815. * @param renderPipelineName The name of the pipeline to attach to
  65816. * @param cameras the camera to attach
  65817. * @param unique if the camera can be attached multiple times to the pipeline
  65818. */
  65819. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65820. /**
  65821. * Detaches a camera from the pipeline
  65822. * @param renderPipelineName The name of the pipeline to detach from
  65823. * @param cameras the camera to detach
  65824. */
  65825. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65826. /**
  65827. * Enables an effect by name on a pipeline
  65828. * @param renderPipelineName the name of the pipeline to enable the effect in
  65829. * @param renderEffectName the name of the effect to enable
  65830. * @param cameras the cameras that the effect should be enabled on
  65831. */
  65832. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65833. /**
  65834. * Disables an effect by name on a pipeline
  65835. * @param renderPipelineName the name of the pipeline to disable the effect in
  65836. * @param renderEffectName the name of the effect to disable
  65837. * @param cameras the cameras that the effect should be disabled on
  65838. */
  65839. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65840. /**
  65841. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65842. */
  65843. update(): void;
  65844. /** @hidden */
  65845. _rebuild(): void;
  65846. /**
  65847. * Disposes of the manager and pipelines
  65848. */
  65849. dispose(): void;
  65850. }
  65851. }
  65852. declare module BABYLON {
  65853. interface Scene {
  65854. /** @hidden (Backing field) */
  65855. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65856. /**
  65857. * Gets the postprocess render pipeline manager
  65858. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65859. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65860. */
  65861. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65862. }
  65863. /**
  65864. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65865. */
  65866. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65867. /**
  65868. * The component name helpfull to identify the component in the list of scene components.
  65869. */
  65870. readonly name: string;
  65871. /**
  65872. * The scene the component belongs to.
  65873. */
  65874. scene: Scene;
  65875. /**
  65876. * Creates a new instance of the component for the given scene
  65877. * @param scene Defines the scene to register the component in
  65878. */
  65879. constructor(scene: Scene);
  65880. /**
  65881. * Registers the component in a given scene
  65882. */
  65883. register(): void;
  65884. /**
  65885. * Rebuilds the elements related to this component in case of
  65886. * context lost for instance.
  65887. */
  65888. rebuild(): void;
  65889. /**
  65890. * Disposes the component and the associated ressources
  65891. */
  65892. dispose(): void;
  65893. private _gatherRenderTargets;
  65894. }
  65895. }
  65896. declare module BABYLON {
  65897. /**
  65898. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65899. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65900. */
  65901. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65902. private _scene;
  65903. private _camerasToBeAttached;
  65904. /**
  65905. * ID of the sharpen post process,
  65906. */
  65907. private readonly SharpenPostProcessId;
  65908. /**
  65909. * @ignore
  65910. * ID of the image processing post process;
  65911. */
  65912. readonly ImageProcessingPostProcessId: string;
  65913. /**
  65914. * @ignore
  65915. * ID of the Fast Approximate Anti-Aliasing post process;
  65916. */
  65917. readonly FxaaPostProcessId: string;
  65918. /**
  65919. * ID of the chromatic aberration post process,
  65920. */
  65921. private readonly ChromaticAberrationPostProcessId;
  65922. /**
  65923. * ID of the grain post process
  65924. */
  65925. private readonly GrainPostProcessId;
  65926. /**
  65927. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65928. */
  65929. sharpen: SharpenPostProcess;
  65930. private _sharpenEffect;
  65931. private bloom;
  65932. /**
  65933. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65934. */
  65935. depthOfField: DepthOfFieldEffect;
  65936. /**
  65937. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65938. */
  65939. fxaa: FxaaPostProcess;
  65940. /**
  65941. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65942. */
  65943. imageProcessing: ImageProcessingPostProcess;
  65944. /**
  65945. * Chromatic aberration post process which will shift rgb colors in the image
  65946. */
  65947. chromaticAberration: ChromaticAberrationPostProcess;
  65948. private _chromaticAberrationEffect;
  65949. /**
  65950. * Grain post process which add noise to the image
  65951. */
  65952. grain: GrainPostProcess;
  65953. private _grainEffect;
  65954. /**
  65955. * Glow post process which adds a glow to emissive areas of the image
  65956. */
  65957. private _glowLayer;
  65958. /**
  65959. * Animations which can be used to tweak settings over a period of time
  65960. */
  65961. animations: Animation[];
  65962. private _imageProcessingConfigurationObserver;
  65963. private _sharpenEnabled;
  65964. private _bloomEnabled;
  65965. private _depthOfFieldEnabled;
  65966. private _depthOfFieldBlurLevel;
  65967. private _fxaaEnabled;
  65968. private _imageProcessingEnabled;
  65969. private _defaultPipelineTextureType;
  65970. private _bloomScale;
  65971. private _chromaticAberrationEnabled;
  65972. private _grainEnabled;
  65973. private _buildAllowed;
  65974. /**
  65975. * Gets active scene
  65976. */
  65977. get scene(): Scene;
  65978. /**
  65979. * Enable or disable the sharpen process from the pipeline
  65980. */
  65981. set sharpenEnabled(enabled: boolean);
  65982. get sharpenEnabled(): boolean;
  65983. private _resizeObserver;
  65984. private _hardwareScaleLevel;
  65985. private _bloomKernel;
  65986. /**
  65987. * Specifies the size of the bloom blur kernel, relative to the final output size
  65988. */
  65989. get bloomKernel(): number;
  65990. set bloomKernel(value: number);
  65991. /**
  65992. * Specifies the weight of the bloom in the final rendering
  65993. */
  65994. private _bloomWeight;
  65995. /**
  65996. * Specifies the luma threshold for the area that will be blurred by the bloom
  65997. */
  65998. private _bloomThreshold;
  65999. private _hdr;
  66000. /**
  66001. * The strength of the bloom.
  66002. */
  66003. set bloomWeight(value: number);
  66004. get bloomWeight(): number;
  66005. /**
  66006. * The strength of the bloom.
  66007. */
  66008. set bloomThreshold(value: number);
  66009. get bloomThreshold(): number;
  66010. /**
  66011. * The scale of the bloom, lower value will provide better performance.
  66012. */
  66013. set bloomScale(value: number);
  66014. get bloomScale(): number;
  66015. /**
  66016. * Enable or disable the bloom from the pipeline
  66017. */
  66018. set bloomEnabled(enabled: boolean);
  66019. get bloomEnabled(): boolean;
  66020. private _rebuildBloom;
  66021. /**
  66022. * If the depth of field is enabled.
  66023. */
  66024. get depthOfFieldEnabled(): boolean;
  66025. set depthOfFieldEnabled(enabled: boolean);
  66026. /**
  66027. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66028. */
  66029. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66030. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66031. /**
  66032. * If the anti aliasing is enabled.
  66033. */
  66034. set fxaaEnabled(enabled: boolean);
  66035. get fxaaEnabled(): boolean;
  66036. private _samples;
  66037. /**
  66038. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66039. */
  66040. set samples(sampleCount: number);
  66041. get samples(): number;
  66042. /**
  66043. * If image processing is enabled.
  66044. */
  66045. set imageProcessingEnabled(enabled: boolean);
  66046. get imageProcessingEnabled(): boolean;
  66047. /**
  66048. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66049. */
  66050. set glowLayerEnabled(enabled: boolean);
  66051. get glowLayerEnabled(): boolean;
  66052. /**
  66053. * Gets the glow layer (or null if not defined)
  66054. */
  66055. get glowLayer(): Nullable<GlowLayer>;
  66056. /**
  66057. * Enable or disable the chromaticAberration process from the pipeline
  66058. */
  66059. set chromaticAberrationEnabled(enabled: boolean);
  66060. get chromaticAberrationEnabled(): boolean;
  66061. /**
  66062. * Enable or disable the grain process from the pipeline
  66063. */
  66064. set grainEnabled(enabled: boolean);
  66065. get grainEnabled(): boolean;
  66066. /**
  66067. * @constructor
  66068. * @param name - The rendering pipeline name (default: "")
  66069. * @param hdr - If high dynamic range textures should be used (default: true)
  66070. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66071. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66072. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66073. */
  66074. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66075. /**
  66076. * Get the class name
  66077. * @returns "DefaultRenderingPipeline"
  66078. */
  66079. getClassName(): string;
  66080. /**
  66081. * Force the compilation of the entire pipeline.
  66082. */
  66083. prepare(): void;
  66084. private _hasCleared;
  66085. private _prevPostProcess;
  66086. private _prevPrevPostProcess;
  66087. private _setAutoClearAndTextureSharing;
  66088. private _depthOfFieldSceneObserver;
  66089. private _buildPipeline;
  66090. private _disposePostProcesses;
  66091. /**
  66092. * Adds a camera to the pipeline
  66093. * @param camera the camera to be added
  66094. */
  66095. addCamera(camera: Camera): void;
  66096. /**
  66097. * Removes a camera from the pipeline
  66098. * @param camera the camera to remove
  66099. */
  66100. removeCamera(camera: Camera): void;
  66101. /**
  66102. * Dispose of the pipeline and stop all post processes
  66103. */
  66104. dispose(): void;
  66105. /**
  66106. * Serialize the rendering pipeline (Used when exporting)
  66107. * @returns the serialized object
  66108. */
  66109. serialize(): any;
  66110. /**
  66111. * Parse the serialized pipeline
  66112. * @param source Source pipeline.
  66113. * @param scene The scene to load the pipeline to.
  66114. * @param rootUrl The URL of the serialized pipeline.
  66115. * @returns An instantiated pipeline from the serialized object.
  66116. */
  66117. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66118. }
  66119. }
  66120. declare module BABYLON {
  66121. /** @hidden */
  66122. export var lensHighlightsPixelShader: {
  66123. name: string;
  66124. shader: string;
  66125. };
  66126. }
  66127. declare module BABYLON {
  66128. /** @hidden */
  66129. export var depthOfFieldPixelShader: {
  66130. name: string;
  66131. shader: string;
  66132. };
  66133. }
  66134. declare module BABYLON {
  66135. /**
  66136. * BABYLON.JS Chromatic Aberration GLSL Shader
  66137. * Author: Olivier Guyot
  66138. * Separates very slightly R, G and B colors on the edges of the screen
  66139. * Inspired by Francois Tarlier & Martins Upitis
  66140. */
  66141. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66142. /**
  66143. * @ignore
  66144. * The chromatic aberration PostProcess id in the pipeline
  66145. */
  66146. LensChromaticAberrationEffect: string;
  66147. /**
  66148. * @ignore
  66149. * The highlights enhancing PostProcess id in the pipeline
  66150. */
  66151. HighlightsEnhancingEffect: string;
  66152. /**
  66153. * @ignore
  66154. * The depth-of-field PostProcess id in the pipeline
  66155. */
  66156. LensDepthOfFieldEffect: string;
  66157. private _scene;
  66158. private _depthTexture;
  66159. private _grainTexture;
  66160. private _chromaticAberrationPostProcess;
  66161. private _highlightsPostProcess;
  66162. private _depthOfFieldPostProcess;
  66163. private _edgeBlur;
  66164. private _grainAmount;
  66165. private _chromaticAberration;
  66166. private _distortion;
  66167. private _highlightsGain;
  66168. private _highlightsThreshold;
  66169. private _dofDistance;
  66170. private _dofAperture;
  66171. private _dofDarken;
  66172. private _dofPentagon;
  66173. private _blurNoise;
  66174. /**
  66175. * @constructor
  66176. *
  66177. * Effect parameters are as follow:
  66178. * {
  66179. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66180. * edge_blur: number; // from 0 to x (1 for realism)
  66181. * distortion: number; // from 0 to x (1 for realism)
  66182. * grain_amount: number; // from 0 to 1
  66183. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66184. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66185. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66186. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66187. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66188. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66189. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66190. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66191. * }
  66192. * Note: if an effect parameter is unset, effect is disabled
  66193. *
  66194. * @param name The rendering pipeline name
  66195. * @param parameters - An object containing all parameters (see above)
  66196. * @param scene The scene linked to this pipeline
  66197. * @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)
  66198. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66199. */
  66200. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66201. /**
  66202. * Get the class name
  66203. * @returns "LensRenderingPipeline"
  66204. */
  66205. getClassName(): string;
  66206. /**
  66207. * Gets associated scene
  66208. */
  66209. get scene(): Scene;
  66210. /**
  66211. * Gets or sets the edge blur
  66212. */
  66213. get edgeBlur(): number;
  66214. set edgeBlur(value: number);
  66215. /**
  66216. * Gets or sets the grain amount
  66217. */
  66218. get grainAmount(): number;
  66219. set grainAmount(value: number);
  66220. /**
  66221. * Gets or sets the chromatic aberration amount
  66222. */
  66223. get chromaticAberration(): number;
  66224. set chromaticAberration(value: number);
  66225. /**
  66226. * Gets or sets the depth of field aperture
  66227. */
  66228. get dofAperture(): number;
  66229. set dofAperture(value: number);
  66230. /**
  66231. * Gets or sets the edge distortion
  66232. */
  66233. get edgeDistortion(): number;
  66234. set edgeDistortion(value: number);
  66235. /**
  66236. * Gets or sets the depth of field distortion
  66237. */
  66238. get dofDistortion(): number;
  66239. set dofDistortion(value: number);
  66240. /**
  66241. * Gets or sets the darken out of focus amount
  66242. */
  66243. get darkenOutOfFocus(): number;
  66244. set darkenOutOfFocus(value: number);
  66245. /**
  66246. * Gets or sets a boolean indicating if blur noise is enabled
  66247. */
  66248. get blurNoise(): boolean;
  66249. set blurNoise(value: boolean);
  66250. /**
  66251. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66252. */
  66253. get pentagonBokeh(): boolean;
  66254. set pentagonBokeh(value: boolean);
  66255. /**
  66256. * Gets or sets the highlight grain amount
  66257. */
  66258. get highlightsGain(): number;
  66259. set highlightsGain(value: number);
  66260. /**
  66261. * Gets or sets the highlight threshold
  66262. */
  66263. get highlightsThreshold(): number;
  66264. set highlightsThreshold(value: number);
  66265. /**
  66266. * Sets the amount of blur at the edges
  66267. * @param amount blur amount
  66268. */
  66269. setEdgeBlur(amount: number): void;
  66270. /**
  66271. * Sets edge blur to 0
  66272. */
  66273. disableEdgeBlur(): void;
  66274. /**
  66275. * Sets the amout of grain
  66276. * @param amount Amount of grain
  66277. */
  66278. setGrainAmount(amount: number): void;
  66279. /**
  66280. * Set grain amount to 0
  66281. */
  66282. disableGrain(): void;
  66283. /**
  66284. * Sets the chromatic aberration amount
  66285. * @param amount amount of chromatic aberration
  66286. */
  66287. setChromaticAberration(amount: number): void;
  66288. /**
  66289. * Sets chromatic aberration amount to 0
  66290. */
  66291. disableChromaticAberration(): void;
  66292. /**
  66293. * Sets the EdgeDistortion amount
  66294. * @param amount amount of EdgeDistortion
  66295. */
  66296. setEdgeDistortion(amount: number): void;
  66297. /**
  66298. * Sets edge distortion to 0
  66299. */
  66300. disableEdgeDistortion(): void;
  66301. /**
  66302. * Sets the FocusDistance amount
  66303. * @param amount amount of FocusDistance
  66304. */
  66305. setFocusDistance(amount: number): void;
  66306. /**
  66307. * Disables depth of field
  66308. */
  66309. disableDepthOfField(): void;
  66310. /**
  66311. * Sets the Aperture amount
  66312. * @param amount amount of Aperture
  66313. */
  66314. setAperture(amount: number): void;
  66315. /**
  66316. * Sets the DarkenOutOfFocus amount
  66317. * @param amount amount of DarkenOutOfFocus
  66318. */
  66319. setDarkenOutOfFocus(amount: number): void;
  66320. private _pentagonBokehIsEnabled;
  66321. /**
  66322. * Creates a pentagon bokeh effect
  66323. */
  66324. enablePentagonBokeh(): void;
  66325. /**
  66326. * Disables the pentagon bokeh effect
  66327. */
  66328. disablePentagonBokeh(): void;
  66329. /**
  66330. * Enables noise blur
  66331. */
  66332. enableNoiseBlur(): void;
  66333. /**
  66334. * Disables noise blur
  66335. */
  66336. disableNoiseBlur(): void;
  66337. /**
  66338. * Sets the HighlightsGain amount
  66339. * @param amount amount of HighlightsGain
  66340. */
  66341. setHighlightsGain(amount: number): void;
  66342. /**
  66343. * Sets the HighlightsThreshold amount
  66344. * @param amount amount of HighlightsThreshold
  66345. */
  66346. setHighlightsThreshold(amount: number): void;
  66347. /**
  66348. * Disables highlights
  66349. */
  66350. disableHighlights(): void;
  66351. /**
  66352. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66353. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66354. */
  66355. dispose(disableDepthRender?: boolean): void;
  66356. private _createChromaticAberrationPostProcess;
  66357. private _createHighlightsPostProcess;
  66358. private _createDepthOfFieldPostProcess;
  66359. private _createGrainTexture;
  66360. }
  66361. }
  66362. declare module BABYLON {
  66363. /** @hidden */
  66364. export var ssao2PixelShader: {
  66365. name: string;
  66366. shader: string;
  66367. };
  66368. }
  66369. declare module BABYLON {
  66370. /** @hidden */
  66371. export var ssaoCombinePixelShader: {
  66372. name: string;
  66373. shader: string;
  66374. };
  66375. }
  66376. declare module BABYLON {
  66377. /**
  66378. * Render pipeline to produce ssao effect
  66379. */
  66380. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66381. /**
  66382. * @ignore
  66383. * The PassPostProcess id in the pipeline that contains the original scene color
  66384. */
  66385. SSAOOriginalSceneColorEffect: string;
  66386. /**
  66387. * @ignore
  66388. * The SSAO PostProcess id in the pipeline
  66389. */
  66390. SSAORenderEffect: string;
  66391. /**
  66392. * @ignore
  66393. * The horizontal blur PostProcess id in the pipeline
  66394. */
  66395. SSAOBlurHRenderEffect: string;
  66396. /**
  66397. * @ignore
  66398. * The vertical blur PostProcess id in the pipeline
  66399. */
  66400. SSAOBlurVRenderEffect: string;
  66401. /**
  66402. * @ignore
  66403. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66404. */
  66405. SSAOCombineRenderEffect: string;
  66406. /**
  66407. * The output strength of the SSAO post-process. Default value is 1.0.
  66408. */
  66409. totalStrength: number;
  66410. /**
  66411. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66412. */
  66413. maxZ: number;
  66414. /**
  66415. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66416. */
  66417. minZAspect: number;
  66418. private _samples;
  66419. /**
  66420. * Number of samples used for the SSAO calculations. Default value is 8
  66421. */
  66422. set samples(n: number);
  66423. get samples(): number;
  66424. private _textureSamples;
  66425. /**
  66426. * Number of samples to use for antialiasing
  66427. */
  66428. set textureSamples(n: number);
  66429. get textureSamples(): number;
  66430. /**
  66431. * Ratio object used for SSAO ratio and blur ratio
  66432. */
  66433. private _ratio;
  66434. /**
  66435. * Dynamically generated sphere sampler.
  66436. */
  66437. private _sampleSphere;
  66438. /**
  66439. * Blur filter offsets
  66440. */
  66441. private _samplerOffsets;
  66442. private _expensiveBlur;
  66443. /**
  66444. * If bilateral blur should be used
  66445. */
  66446. set expensiveBlur(b: boolean);
  66447. get expensiveBlur(): boolean;
  66448. /**
  66449. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66450. */
  66451. radius: number;
  66452. /**
  66453. * The base color of the SSAO post-process
  66454. * The final result is "base + ssao" between [0, 1]
  66455. */
  66456. base: number;
  66457. /**
  66458. * Support test.
  66459. */
  66460. static get IsSupported(): boolean;
  66461. private _scene;
  66462. private _depthTexture;
  66463. private _normalTexture;
  66464. private _randomTexture;
  66465. private _originalColorPostProcess;
  66466. private _ssaoPostProcess;
  66467. private _blurHPostProcess;
  66468. private _blurVPostProcess;
  66469. private _ssaoCombinePostProcess;
  66470. /**
  66471. * Gets active scene
  66472. */
  66473. get scene(): Scene;
  66474. /**
  66475. * @constructor
  66476. * @param name The rendering pipeline name
  66477. * @param scene The scene linked to this pipeline
  66478. * @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 }
  66479. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66480. */
  66481. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66482. /**
  66483. * Get the class name
  66484. * @returns "SSAO2RenderingPipeline"
  66485. */
  66486. getClassName(): string;
  66487. /**
  66488. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66489. */
  66490. dispose(disableGeometryBufferRenderer?: boolean): void;
  66491. private _createBlurPostProcess;
  66492. /** @hidden */
  66493. _rebuild(): void;
  66494. private _bits;
  66495. private _radicalInverse_VdC;
  66496. private _hammersley;
  66497. private _hemisphereSample_uniform;
  66498. private _generateHemisphere;
  66499. private _createSSAOPostProcess;
  66500. private _createSSAOCombinePostProcess;
  66501. private _createRandomTexture;
  66502. /**
  66503. * Serialize the rendering pipeline (Used when exporting)
  66504. * @returns the serialized object
  66505. */
  66506. serialize(): any;
  66507. /**
  66508. * Parse the serialized pipeline
  66509. * @param source Source pipeline.
  66510. * @param scene The scene to load the pipeline to.
  66511. * @param rootUrl The URL of the serialized pipeline.
  66512. * @returns An instantiated pipeline from the serialized object.
  66513. */
  66514. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66515. }
  66516. }
  66517. declare module BABYLON {
  66518. /** @hidden */
  66519. export var ssaoPixelShader: {
  66520. name: string;
  66521. shader: string;
  66522. };
  66523. }
  66524. declare module BABYLON {
  66525. /**
  66526. * Render pipeline to produce ssao effect
  66527. */
  66528. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66529. /**
  66530. * @ignore
  66531. * The PassPostProcess id in the pipeline that contains the original scene color
  66532. */
  66533. SSAOOriginalSceneColorEffect: string;
  66534. /**
  66535. * @ignore
  66536. * The SSAO PostProcess id in the pipeline
  66537. */
  66538. SSAORenderEffect: string;
  66539. /**
  66540. * @ignore
  66541. * The horizontal blur PostProcess id in the pipeline
  66542. */
  66543. SSAOBlurHRenderEffect: string;
  66544. /**
  66545. * @ignore
  66546. * The vertical blur PostProcess id in the pipeline
  66547. */
  66548. SSAOBlurVRenderEffect: string;
  66549. /**
  66550. * @ignore
  66551. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66552. */
  66553. SSAOCombineRenderEffect: string;
  66554. /**
  66555. * The output strength of the SSAO post-process. Default value is 1.0.
  66556. */
  66557. totalStrength: number;
  66558. /**
  66559. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66560. */
  66561. radius: number;
  66562. /**
  66563. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66564. * Must not be equal to fallOff and superior to fallOff.
  66565. * Default value is 0.0075
  66566. */
  66567. area: number;
  66568. /**
  66569. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66570. * Must not be equal to area and inferior to area.
  66571. * Default value is 0.000001
  66572. */
  66573. fallOff: number;
  66574. /**
  66575. * The base color of the SSAO post-process
  66576. * The final result is "base + ssao" between [0, 1]
  66577. */
  66578. base: number;
  66579. private _scene;
  66580. private _depthTexture;
  66581. private _randomTexture;
  66582. private _originalColorPostProcess;
  66583. private _ssaoPostProcess;
  66584. private _blurHPostProcess;
  66585. private _blurVPostProcess;
  66586. private _ssaoCombinePostProcess;
  66587. private _firstUpdate;
  66588. /**
  66589. * Gets active scene
  66590. */
  66591. get scene(): Scene;
  66592. /**
  66593. * @constructor
  66594. * @param name - The rendering pipeline name
  66595. * @param scene - The scene linked to this pipeline
  66596. * @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 }
  66597. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66598. */
  66599. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66600. /**
  66601. * Get the class name
  66602. * @returns "SSAORenderingPipeline"
  66603. */
  66604. getClassName(): string;
  66605. /**
  66606. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66607. */
  66608. dispose(disableDepthRender?: boolean): void;
  66609. private _createBlurPostProcess;
  66610. /** @hidden */
  66611. _rebuild(): void;
  66612. private _createSSAOPostProcess;
  66613. private _createSSAOCombinePostProcess;
  66614. private _createRandomTexture;
  66615. }
  66616. }
  66617. declare module BABYLON {
  66618. /** @hidden */
  66619. export var screenSpaceReflectionPixelShader: {
  66620. name: string;
  66621. shader: string;
  66622. };
  66623. }
  66624. declare module BABYLON {
  66625. /**
  66626. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66627. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66628. */
  66629. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66630. /**
  66631. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66632. */
  66633. threshold: number;
  66634. /**
  66635. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66636. */
  66637. strength: number;
  66638. /**
  66639. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66640. */
  66641. reflectionSpecularFalloffExponent: number;
  66642. /**
  66643. * 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]
  66644. */
  66645. step: number;
  66646. /**
  66647. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66648. */
  66649. roughnessFactor: number;
  66650. private _geometryBufferRenderer;
  66651. private _enableSmoothReflections;
  66652. private _reflectionSamples;
  66653. private _smoothSteps;
  66654. /**
  66655. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66656. * @param name The name of the effect.
  66657. * @param scene The scene containing the objects to calculate reflections.
  66658. * @param options The required width/height ratio to downsize to before computing the render pass.
  66659. * @param camera The camera to apply the render pass to.
  66660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66661. * @param engine The engine which the post process will be applied. (default: current engine)
  66662. * @param reusable If the post process can be reused on the same frame. (default: false)
  66663. * @param textureType Type of textures used when performing the post process. (default: 0)
  66664. * @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)
  66665. */
  66666. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66667. /**
  66668. * Gets wether or not smoothing reflections is enabled.
  66669. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66670. */
  66671. get enableSmoothReflections(): boolean;
  66672. /**
  66673. * Sets wether or not smoothing reflections is enabled.
  66674. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66675. */
  66676. set enableSmoothReflections(enabled: boolean);
  66677. /**
  66678. * Gets the number of samples taken while computing reflections. More samples count is high,
  66679. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66680. */
  66681. get reflectionSamples(): number;
  66682. /**
  66683. * Sets the number of samples taken while computing reflections. More samples count is high,
  66684. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66685. */
  66686. set reflectionSamples(samples: number);
  66687. /**
  66688. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66689. * more the post-process will require GPU power and can generate a drop in FPS.
  66690. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66691. */
  66692. get smoothSteps(): number;
  66693. set smoothSteps(steps: number);
  66694. private _updateEffectDefines;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /** @hidden */
  66699. export var standardPixelShader: {
  66700. name: string;
  66701. shader: string;
  66702. };
  66703. }
  66704. declare module BABYLON {
  66705. /**
  66706. * Standard rendering pipeline
  66707. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66708. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66709. */
  66710. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66711. /**
  66712. * Public members
  66713. */
  66714. /**
  66715. * Post-process which contains the original scene color before the pipeline applies all the effects
  66716. */
  66717. originalPostProcess: Nullable<PostProcess>;
  66718. /**
  66719. * Post-process used to down scale an image x4
  66720. */
  66721. downSampleX4PostProcess: Nullable<PostProcess>;
  66722. /**
  66723. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66724. */
  66725. brightPassPostProcess: Nullable<PostProcess>;
  66726. /**
  66727. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66728. */
  66729. blurHPostProcesses: PostProcess[];
  66730. /**
  66731. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66732. */
  66733. blurVPostProcesses: PostProcess[];
  66734. /**
  66735. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66736. */
  66737. textureAdderPostProcess: Nullable<PostProcess>;
  66738. /**
  66739. * Post-process used to create volumetric lighting effect
  66740. */
  66741. volumetricLightPostProcess: Nullable<PostProcess>;
  66742. /**
  66743. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66744. */
  66745. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66746. /**
  66747. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66748. */
  66749. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66750. /**
  66751. * Post-process used to merge the volumetric light effect and the real scene color
  66752. */
  66753. volumetricLightMergePostProces: Nullable<PostProcess>;
  66754. /**
  66755. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66756. */
  66757. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66758. /**
  66759. * Base post-process used to calculate the average luminance of the final image for HDR
  66760. */
  66761. luminancePostProcess: Nullable<PostProcess>;
  66762. /**
  66763. * Post-processes used to create down sample post-processes in order to get
  66764. * the average luminance of the final image for HDR
  66765. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66766. */
  66767. luminanceDownSamplePostProcesses: PostProcess[];
  66768. /**
  66769. * Post-process used to create a HDR effect (light adaptation)
  66770. */
  66771. hdrPostProcess: Nullable<PostProcess>;
  66772. /**
  66773. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66774. */
  66775. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66776. /**
  66777. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66778. */
  66779. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66780. /**
  66781. * Post-process used to merge the final HDR post-process and the real scene color
  66782. */
  66783. hdrFinalPostProcess: Nullable<PostProcess>;
  66784. /**
  66785. * Post-process used to create a lens flare effect
  66786. */
  66787. lensFlarePostProcess: Nullable<PostProcess>;
  66788. /**
  66789. * Post-process that merges the result of the lens flare post-process and the real scene color
  66790. */
  66791. lensFlareComposePostProcess: Nullable<PostProcess>;
  66792. /**
  66793. * Post-process used to create a motion blur effect
  66794. */
  66795. motionBlurPostProcess: Nullable<PostProcess>;
  66796. /**
  66797. * Post-process used to create a depth of field effect
  66798. */
  66799. depthOfFieldPostProcess: Nullable<PostProcess>;
  66800. /**
  66801. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66802. */
  66803. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66804. /**
  66805. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66806. */
  66807. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66808. /**
  66809. * Represents the brightness threshold in order to configure the illuminated surfaces
  66810. */
  66811. brightThreshold: number;
  66812. /**
  66813. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66814. */
  66815. blurWidth: number;
  66816. /**
  66817. * Sets if the blur for highlighted surfaces must be only horizontal
  66818. */
  66819. horizontalBlur: boolean;
  66820. /**
  66821. * Gets the overall exposure used by the pipeline
  66822. */
  66823. get exposure(): number;
  66824. /**
  66825. * Sets the overall exposure used by the pipeline
  66826. */
  66827. set exposure(value: number);
  66828. /**
  66829. * Texture used typically to simulate "dirty" on camera lens
  66830. */
  66831. lensTexture: Nullable<Texture>;
  66832. /**
  66833. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66834. */
  66835. volumetricLightCoefficient: number;
  66836. /**
  66837. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66838. */
  66839. volumetricLightPower: number;
  66840. /**
  66841. * Used the set the blur intensity to smooth the volumetric lights
  66842. */
  66843. volumetricLightBlurScale: number;
  66844. /**
  66845. * Light (spot or directional) used to generate the volumetric lights rays
  66846. * The source light must have a shadow generate so the pipeline can get its
  66847. * depth map
  66848. */
  66849. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66850. /**
  66851. * For eye adaptation, represents the minimum luminance the eye can see
  66852. */
  66853. hdrMinimumLuminance: number;
  66854. /**
  66855. * For eye adaptation, represents the decrease luminance speed
  66856. */
  66857. hdrDecreaseRate: number;
  66858. /**
  66859. * For eye adaptation, represents the increase luminance speed
  66860. */
  66861. hdrIncreaseRate: number;
  66862. /**
  66863. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66864. */
  66865. get hdrAutoExposure(): boolean;
  66866. /**
  66867. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66868. */
  66869. set hdrAutoExposure(value: boolean);
  66870. /**
  66871. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66872. */
  66873. lensColorTexture: Nullable<Texture>;
  66874. /**
  66875. * The overall strengh for the lens flare effect
  66876. */
  66877. lensFlareStrength: number;
  66878. /**
  66879. * Dispersion coefficient for lens flare ghosts
  66880. */
  66881. lensFlareGhostDispersal: number;
  66882. /**
  66883. * Main lens flare halo width
  66884. */
  66885. lensFlareHaloWidth: number;
  66886. /**
  66887. * Based on the lens distortion effect, defines how much the lens flare result
  66888. * is distorted
  66889. */
  66890. lensFlareDistortionStrength: number;
  66891. /**
  66892. * Configures the blur intensity used for for lens flare (halo)
  66893. */
  66894. lensFlareBlurWidth: number;
  66895. /**
  66896. * Lens star texture must be used to simulate rays on the flares and is available
  66897. * in the documentation
  66898. */
  66899. lensStarTexture: Nullable<Texture>;
  66900. /**
  66901. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66902. * flare effect by taking account of the dirt texture
  66903. */
  66904. lensFlareDirtTexture: Nullable<Texture>;
  66905. /**
  66906. * Represents the focal length for the depth of field effect
  66907. */
  66908. depthOfFieldDistance: number;
  66909. /**
  66910. * Represents the blur intensity for the blurred part of the depth of field effect
  66911. */
  66912. depthOfFieldBlurWidth: number;
  66913. /**
  66914. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66915. */
  66916. get motionStrength(): number;
  66917. /**
  66918. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66919. */
  66920. set motionStrength(strength: number);
  66921. /**
  66922. * Gets wether or not the motion blur post-process is object based or screen based.
  66923. */
  66924. get objectBasedMotionBlur(): boolean;
  66925. /**
  66926. * Sets wether or not the motion blur post-process should be object based or screen based
  66927. */
  66928. set objectBasedMotionBlur(value: boolean);
  66929. /**
  66930. * List of animations for the pipeline (IAnimatable implementation)
  66931. */
  66932. animations: Animation[];
  66933. /**
  66934. * Private members
  66935. */
  66936. private _scene;
  66937. private _currentDepthOfFieldSource;
  66938. private _basePostProcess;
  66939. private _fixedExposure;
  66940. private _currentExposure;
  66941. private _hdrAutoExposure;
  66942. private _hdrCurrentLuminance;
  66943. private _motionStrength;
  66944. private _isObjectBasedMotionBlur;
  66945. private _floatTextureType;
  66946. private _camerasToBeAttached;
  66947. private _ratio;
  66948. private _bloomEnabled;
  66949. private _depthOfFieldEnabled;
  66950. private _vlsEnabled;
  66951. private _lensFlareEnabled;
  66952. private _hdrEnabled;
  66953. private _motionBlurEnabled;
  66954. private _fxaaEnabled;
  66955. private _screenSpaceReflectionsEnabled;
  66956. private _motionBlurSamples;
  66957. private _volumetricLightStepsCount;
  66958. private _samples;
  66959. /**
  66960. * @ignore
  66961. * Specifies if the bloom pipeline is enabled
  66962. */
  66963. get BloomEnabled(): boolean;
  66964. set BloomEnabled(enabled: boolean);
  66965. /**
  66966. * @ignore
  66967. * Specifies if the depth of field pipeline is enabed
  66968. */
  66969. get DepthOfFieldEnabled(): boolean;
  66970. set DepthOfFieldEnabled(enabled: boolean);
  66971. /**
  66972. * @ignore
  66973. * Specifies if the lens flare pipeline is enabed
  66974. */
  66975. get LensFlareEnabled(): boolean;
  66976. set LensFlareEnabled(enabled: boolean);
  66977. /**
  66978. * @ignore
  66979. * Specifies if the HDR pipeline is enabled
  66980. */
  66981. get HDREnabled(): boolean;
  66982. set HDREnabled(enabled: boolean);
  66983. /**
  66984. * @ignore
  66985. * Specifies if the volumetric lights scattering effect is enabled
  66986. */
  66987. get VLSEnabled(): boolean;
  66988. set VLSEnabled(enabled: boolean);
  66989. /**
  66990. * @ignore
  66991. * Specifies if the motion blur effect is enabled
  66992. */
  66993. get MotionBlurEnabled(): boolean;
  66994. set MotionBlurEnabled(enabled: boolean);
  66995. /**
  66996. * Specifies if anti-aliasing is enabled
  66997. */
  66998. get fxaaEnabled(): boolean;
  66999. set fxaaEnabled(enabled: boolean);
  67000. /**
  67001. * Specifies if screen space reflections are enabled.
  67002. */
  67003. get screenSpaceReflectionsEnabled(): boolean;
  67004. set screenSpaceReflectionsEnabled(enabled: boolean);
  67005. /**
  67006. * Specifies the number of steps used to calculate the volumetric lights
  67007. * Typically in interval [50, 200]
  67008. */
  67009. get volumetricLightStepsCount(): number;
  67010. set volumetricLightStepsCount(count: number);
  67011. /**
  67012. * Specifies the number of samples used for the motion blur effect
  67013. * Typically in interval [16, 64]
  67014. */
  67015. get motionBlurSamples(): number;
  67016. set motionBlurSamples(samples: number);
  67017. /**
  67018. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67019. */
  67020. get samples(): number;
  67021. set samples(sampleCount: number);
  67022. /**
  67023. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67024. * @constructor
  67025. * @param name The rendering pipeline name
  67026. * @param scene The scene linked to this pipeline
  67027. * @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)
  67028. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67029. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67030. */
  67031. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67032. private _buildPipeline;
  67033. private _createDownSampleX4PostProcess;
  67034. private _createBrightPassPostProcess;
  67035. private _createBlurPostProcesses;
  67036. private _createTextureAdderPostProcess;
  67037. private _createVolumetricLightPostProcess;
  67038. private _createLuminancePostProcesses;
  67039. private _createHdrPostProcess;
  67040. private _createLensFlarePostProcess;
  67041. private _createDepthOfFieldPostProcess;
  67042. private _createMotionBlurPostProcess;
  67043. private _getDepthTexture;
  67044. private _disposePostProcesses;
  67045. /**
  67046. * Dispose of the pipeline and stop all post processes
  67047. */
  67048. dispose(): void;
  67049. /**
  67050. * Serialize the rendering pipeline (Used when exporting)
  67051. * @returns the serialized object
  67052. */
  67053. serialize(): any;
  67054. /**
  67055. * Parse the serialized pipeline
  67056. * @param source Source pipeline.
  67057. * @param scene The scene to load the pipeline to.
  67058. * @param rootUrl The URL of the serialized pipeline.
  67059. * @returns An instantiated pipeline from the serialized object.
  67060. */
  67061. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67062. /**
  67063. * Luminance steps
  67064. */
  67065. static LuminanceSteps: number;
  67066. }
  67067. }
  67068. declare module BABYLON {
  67069. /** @hidden */
  67070. export var tonemapPixelShader: {
  67071. name: string;
  67072. shader: string;
  67073. };
  67074. }
  67075. declare module BABYLON {
  67076. /** Defines operator used for tonemapping */
  67077. export enum TonemappingOperator {
  67078. /** Hable */
  67079. Hable = 0,
  67080. /** Reinhard */
  67081. Reinhard = 1,
  67082. /** HejiDawson */
  67083. HejiDawson = 2,
  67084. /** Photographic */
  67085. Photographic = 3
  67086. }
  67087. /**
  67088. * Defines a post process to apply tone mapping
  67089. */
  67090. export class TonemapPostProcess extends PostProcess {
  67091. private _operator;
  67092. /** Defines the required exposure adjustement */
  67093. exposureAdjustment: number;
  67094. /**
  67095. * Creates a new TonemapPostProcess
  67096. * @param name defines the name of the postprocess
  67097. * @param _operator defines the operator to use
  67098. * @param exposureAdjustment defines the required exposure adjustement
  67099. * @param camera defines the camera to use (can be null)
  67100. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67101. * @param engine defines the hosting engine (can be ignore if camera is set)
  67102. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67103. */
  67104. constructor(name: string, _operator: TonemappingOperator,
  67105. /** Defines the required exposure adjustement */
  67106. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67107. }
  67108. }
  67109. declare module BABYLON {
  67110. /** @hidden */
  67111. export var volumetricLightScatteringPixelShader: {
  67112. name: string;
  67113. shader: string;
  67114. };
  67115. }
  67116. declare module BABYLON {
  67117. /** @hidden */
  67118. export var volumetricLightScatteringPassVertexShader: {
  67119. name: string;
  67120. shader: string;
  67121. };
  67122. }
  67123. declare module BABYLON {
  67124. /** @hidden */
  67125. export var volumetricLightScatteringPassPixelShader: {
  67126. name: string;
  67127. shader: string;
  67128. };
  67129. }
  67130. declare module BABYLON {
  67131. /**
  67132. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67133. */
  67134. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67135. private _volumetricLightScatteringPass;
  67136. private _volumetricLightScatteringRTT;
  67137. private _viewPort;
  67138. private _screenCoordinates;
  67139. private _cachedDefines;
  67140. /**
  67141. * If not undefined, the mesh position is computed from the attached node position
  67142. */
  67143. attachedNode: {
  67144. position: Vector3;
  67145. };
  67146. /**
  67147. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67148. */
  67149. customMeshPosition: Vector3;
  67150. /**
  67151. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67152. */
  67153. useCustomMeshPosition: boolean;
  67154. /**
  67155. * If the post-process should inverse the light scattering direction
  67156. */
  67157. invert: boolean;
  67158. /**
  67159. * The internal mesh used by the post-process
  67160. */
  67161. mesh: Mesh;
  67162. /**
  67163. * @hidden
  67164. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67165. */
  67166. get useDiffuseColor(): boolean;
  67167. set useDiffuseColor(useDiffuseColor: boolean);
  67168. /**
  67169. * Array containing the excluded meshes not rendered in the internal pass
  67170. */
  67171. excludedMeshes: AbstractMesh[];
  67172. /**
  67173. * Controls the overall intensity of the post-process
  67174. */
  67175. exposure: number;
  67176. /**
  67177. * Dissipates each sample's contribution in range [0, 1]
  67178. */
  67179. decay: number;
  67180. /**
  67181. * Controls the overall intensity of each sample
  67182. */
  67183. weight: number;
  67184. /**
  67185. * Controls the density of each sample
  67186. */
  67187. density: number;
  67188. /**
  67189. * @constructor
  67190. * @param name The post-process name
  67191. * @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)
  67192. * @param camera The camera that the post-process will be attached to
  67193. * @param mesh The mesh used to create the light scattering
  67194. * @param samples The post-process quality, default 100
  67195. * @param samplingModeThe post-process filtering mode
  67196. * @param engine The babylon engine
  67197. * @param reusable If the post-process is reusable
  67198. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67199. */
  67200. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67201. /**
  67202. * Returns the string "VolumetricLightScatteringPostProcess"
  67203. * @returns "VolumetricLightScatteringPostProcess"
  67204. */
  67205. getClassName(): string;
  67206. private _isReady;
  67207. /**
  67208. * Sets the new light position for light scattering effect
  67209. * @param position The new custom light position
  67210. */
  67211. setCustomMeshPosition(position: Vector3): void;
  67212. /**
  67213. * Returns the light position for light scattering effect
  67214. * @return Vector3 The custom light position
  67215. */
  67216. getCustomMeshPosition(): Vector3;
  67217. /**
  67218. * Disposes the internal assets and detaches the post-process from the camera
  67219. */
  67220. dispose(camera: Camera): void;
  67221. /**
  67222. * Returns the render target texture used by the post-process
  67223. * @return the render target texture used by the post-process
  67224. */
  67225. getPass(): RenderTargetTexture;
  67226. private _meshExcluded;
  67227. private _createPass;
  67228. private _updateMeshScreenCoordinates;
  67229. /**
  67230. * Creates a default mesh for the Volumeric Light Scattering post-process
  67231. * @param name The mesh name
  67232. * @param scene The scene where to create the mesh
  67233. * @return the default mesh
  67234. */
  67235. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67236. }
  67237. }
  67238. declare module BABYLON {
  67239. interface Scene {
  67240. /** @hidden (Backing field) */
  67241. _boundingBoxRenderer: BoundingBoxRenderer;
  67242. /** @hidden (Backing field) */
  67243. _forceShowBoundingBoxes: boolean;
  67244. /**
  67245. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67246. */
  67247. forceShowBoundingBoxes: boolean;
  67248. /**
  67249. * Gets the bounding box renderer associated with the scene
  67250. * @returns a BoundingBoxRenderer
  67251. */
  67252. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67253. }
  67254. interface AbstractMesh {
  67255. /** @hidden (Backing field) */
  67256. _showBoundingBox: boolean;
  67257. /**
  67258. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67259. */
  67260. showBoundingBox: boolean;
  67261. }
  67262. /**
  67263. * Component responsible of rendering the bounding box of the meshes in a scene.
  67264. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67265. */
  67266. export class BoundingBoxRenderer implements ISceneComponent {
  67267. /**
  67268. * The component name helpfull to identify the component in the list of scene components.
  67269. */
  67270. readonly name: string;
  67271. /**
  67272. * The scene the component belongs to.
  67273. */
  67274. scene: Scene;
  67275. /**
  67276. * Color of the bounding box lines placed in front of an object
  67277. */
  67278. frontColor: Color3;
  67279. /**
  67280. * Color of the bounding box lines placed behind an object
  67281. */
  67282. backColor: Color3;
  67283. /**
  67284. * Defines if the renderer should show the back lines or not
  67285. */
  67286. showBackLines: boolean;
  67287. /**
  67288. * @hidden
  67289. */
  67290. renderList: SmartArray<BoundingBox>;
  67291. private _colorShader;
  67292. private _vertexBuffers;
  67293. private _indexBuffer;
  67294. private _fillIndexBuffer;
  67295. private _fillIndexData;
  67296. /**
  67297. * Instantiates a new bounding box renderer in a scene.
  67298. * @param scene the scene the renderer renders in
  67299. */
  67300. constructor(scene: Scene);
  67301. /**
  67302. * Registers the component in a given scene
  67303. */
  67304. register(): void;
  67305. private _evaluateSubMesh;
  67306. private _activeMesh;
  67307. private _prepareRessources;
  67308. private _createIndexBuffer;
  67309. /**
  67310. * Rebuilds the elements related to this component in case of
  67311. * context lost for instance.
  67312. */
  67313. rebuild(): void;
  67314. /**
  67315. * @hidden
  67316. */
  67317. reset(): void;
  67318. /**
  67319. * Render the bounding boxes of a specific rendering group
  67320. * @param renderingGroupId defines the rendering group to render
  67321. */
  67322. render(renderingGroupId: number): void;
  67323. /**
  67324. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67325. * @param mesh Define the mesh to render the occlusion bounding box for
  67326. */
  67327. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67328. /**
  67329. * Dispose and release the resources attached to this renderer.
  67330. */
  67331. dispose(): void;
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. interface Scene {
  67336. /** @hidden (Backing field) */
  67337. _depthRenderer: {
  67338. [id: string]: DepthRenderer;
  67339. };
  67340. /**
  67341. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67342. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67343. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67344. * @returns the created depth renderer
  67345. */
  67346. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67347. /**
  67348. * Disables a depth renderer for a given camera
  67349. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67350. */
  67351. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67352. }
  67353. /**
  67354. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67355. * in several rendering techniques.
  67356. */
  67357. export class DepthRendererSceneComponent implements ISceneComponent {
  67358. /**
  67359. * The component name helpfull to identify the component in the list of scene components.
  67360. */
  67361. readonly name: string;
  67362. /**
  67363. * The scene the component belongs to.
  67364. */
  67365. scene: Scene;
  67366. /**
  67367. * Creates a new instance of the component for the given scene
  67368. * @param scene Defines the scene to register the component in
  67369. */
  67370. constructor(scene: Scene);
  67371. /**
  67372. * Registers the component in a given scene
  67373. */
  67374. register(): void;
  67375. /**
  67376. * Rebuilds the elements related to this component in case of
  67377. * context lost for instance.
  67378. */
  67379. rebuild(): void;
  67380. /**
  67381. * Disposes the component and the associated ressources
  67382. */
  67383. dispose(): void;
  67384. private _gatherRenderTargets;
  67385. private _gatherActiveCameraRenderTargets;
  67386. }
  67387. }
  67388. declare module BABYLON {
  67389. /** @hidden */
  67390. export var outlinePixelShader: {
  67391. name: string;
  67392. shader: string;
  67393. };
  67394. }
  67395. declare module BABYLON {
  67396. /** @hidden */
  67397. export var outlineVertexShader: {
  67398. name: string;
  67399. shader: string;
  67400. };
  67401. }
  67402. declare module BABYLON {
  67403. interface Scene {
  67404. /** @hidden */
  67405. _outlineRenderer: OutlineRenderer;
  67406. /**
  67407. * Gets the outline renderer associated with the scene
  67408. * @returns a OutlineRenderer
  67409. */
  67410. getOutlineRenderer(): OutlineRenderer;
  67411. }
  67412. interface AbstractMesh {
  67413. /** @hidden (Backing field) */
  67414. _renderOutline: boolean;
  67415. /**
  67416. * Gets or sets a boolean indicating if the outline must be rendered as well
  67417. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67418. */
  67419. renderOutline: boolean;
  67420. /** @hidden (Backing field) */
  67421. _renderOverlay: boolean;
  67422. /**
  67423. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67424. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67425. */
  67426. renderOverlay: boolean;
  67427. }
  67428. /**
  67429. * This class is responsible to draw bothe outline/overlay of meshes.
  67430. * It should not be used directly but through the available method on mesh.
  67431. */
  67432. export class OutlineRenderer implements ISceneComponent {
  67433. /**
  67434. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67435. */
  67436. private static _StencilReference;
  67437. /**
  67438. * The name of the component. Each component must have a unique name.
  67439. */
  67440. name: string;
  67441. /**
  67442. * The scene the component belongs to.
  67443. */
  67444. scene: Scene;
  67445. /**
  67446. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67447. */
  67448. zOffset: number;
  67449. private _engine;
  67450. private _effect;
  67451. private _cachedDefines;
  67452. private _savedDepthWrite;
  67453. /**
  67454. * Instantiates a new outline renderer. (There could be only one per scene).
  67455. * @param scene Defines the scene it belongs to
  67456. */
  67457. constructor(scene: Scene);
  67458. /**
  67459. * Register the component to one instance of a scene.
  67460. */
  67461. register(): void;
  67462. /**
  67463. * Rebuilds the elements related to this component in case of
  67464. * context lost for instance.
  67465. */
  67466. rebuild(): void;
  67467. /**
  67468. * Disposes the component and the associated ressources.
  67469. */
  67470. dispose(): void;
  67471. /**
  67472. * Renders the outline in the canvas.
  67473. * @param subMesh Defines the sumesh to render
  67474. * @param batch Defines the batch of meshes in case of instances
  67475. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67476. */
  67477. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67478. /**
  67479. * Returns whether or not the outline renderer is ready for a given submesh.
  67480. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67481. * @param subMesh Defines the submesh to check readyness for
  67482. * @param useInstances Defines wheter wee are trying to render instances or not
  67483. * @returns true if ready otherwise false
  67484. */
  67485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67486. private _beforeRenderingMesh;
  67487. private _afterRenderingMesh;
  67488. }
  67489. }
  67490. declare module BABYLON {
  67491. /**
  67492. * Defines the basic options interface of a Sprite Frame Source Size.
  67493. */
  67494. export interface ISpriteJSONSpriteSourceSize {
  67495. /**
  67496. * number of the original width of the Frame
  67497. */
  67498. w: number;
  67499. /**
  67500. * number of the original height of the Frame
  67501. */
  67502. h: number;
  67503. }
  67504. /**
  67505. * Defines the basic options interface of a Sprite Frame Data.
  67506. */
  67507. export interface ISpriteJSONSpriteFrameData {
  67508. /**
  67509. * number of the x offset of the Frame
  67510. */
  67511. x: number;
  67512. /**
  67513. * number of the y offset of the Frame
  67514. */
  67515. y: number;
  67516. /**
  67517. * number of the width of the Frame
  67518. */
  67519. w: number;
  67520. /**
  67521. * number of the height of the Frame
  67522. */
  67523. h: number;
  67524. }
  67525. /**
  67526. * Defines the basic options interface of a JSON Sprite.
  67527. */
  67528. export interface ISpriteJSONSprite {
  67529. /**
  67530. * string name of the Frame
  67531. */
  67532. filename: string;
  67533. /**
  67534. * ISpriteJSONSpriteFrame basic object of the frame data
  67535. */
  67536. frame: ISpriteJSONSpriteFrameData;
  67537. /**
  67538. * boolean to flag is the frame was rotated.
  67539. */
  67540. rotated: boolean;
  67541. /**
  67542. * boolean to flag is the frame was trimmed.
  67543. */
  67544. trimmed: boolean;
  67545. /**
  67546. * ISpriteJSONSpriteFrame basic object of the source data
  67547. */
  67548. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67549. /**
  67550. * ISpriteJSONSpriteFrame basic object of the source data
  67551. */
  67552. sourceSize: ISpriteJSONSpriteSourceSize;
  67553. }
  67554. /**
  67555. * Defines the basic options interface of a JSON atlas.
  67556. */
  67557. export interface ISpriteJSONAtlas {
  67558. /**
  67559. * Array of objects that contain the frame data.
  67560. */
  67561. frames: Array<ISpriteJSONSprite>;
  67562. /**
  67563. * object basic object containing the sprite meta data.
  67564. */
  67565. meta?: object;
  67566. }
  67567. }
  67568. declare module BABYLON {
  67569. /** @hidden */
  67570. export var spriteMapPixelShader: {
  67571. name: string;
  67572. shader: string;
  67573. };
  67574. }
  67575. declare module BABYLON {
  67576. /** @hidden */
  67577. export var spriteMapVertexShader: {
  67578. name: string;
  67579. shader: string;
  67580. };
  67581. }
  67582. declare module BABYLON {
  67583. /**
  67584. * Defines the basic options interface of a SpriteMap
  67585. */
  67586. export interface ISpriteMapOptions {
  67587. /**
  67588. * Vector2 of the number of cells in the grid.
  67589. */
  67590. stageSize?: Vector2;
  67591. /**
  67592. * Vector2 of the size of the output plane in World Units.
  67593. */
  67594. outputSize?: Vector2;
  67595. /**
  67596. * Vector3 of the position of the output plane in World Units.
  67597. */
  67598. outputPosition?: Vector3;
  67599. /**
  67600. * Vector3 of the rotation of the output plane.
  67601. */
  67602. outputRotation?: Vector3;
  67603. /**
  67604. * number of layers that the system will reserve in resources.
  67605. */
  67606. layerCount?: number;
  67607. /**
  67608. * number of max animation frames a single cell will reserve in resources.
  67609. */
  67610. maxAnimationFrames?: number;
  67611. /**
  67612. * number cell index of the base tile when the system compiles.
  67613. */
  67614. baseTile?: number;
  67615. /**
  67616. * boolean flip the sprite after its been repositioned by the framing data.
  67617. */
  67618. flipU?: boolean;
  67619. /**
  67620. * Vector3 scalar of the global RGB values of the SpriteMap.
  67621. */
  67622. colorMultiply?: Vector3;
  67623. }
  67624. /**
  67625. * Defines the IDisposable interface in order to be cleanable from resources.
  67626. */
  67627. export interface ISpriteMap extends IDisposable {
  67628. /**
  67629. * String name of the SpriteMap.
  67630. */
  67631. name: string;
  67632. /**
  67633. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67634. */
  67635. atlasJSON: ISpriteJSONAtlas;
  67636. /**
  67637. * Texture of the SpriteMap.
  67638. */
  67639. spriteSheet: Texture;
  67640. /**
  67641. * The parameters to initialize the SpriteMap with.
  67642. */
  67643. options: ISpriteMapOptions;
  67644. }
  67645. /**
  67646. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67647. */
  67648. export class SpriteMap implements ISpriteMap {
  67649. /** The Name of the spriteMap */
  67650. name: string;
  67651. /** The JSON file with the frame and meta data */
  67652. atlasJSON: ISpriteJSONAtlas;
  67653. /** The systems Sprite Sheet Texture */
  67654. spriteSheet: Texture;
  67655. /** Arguments passed with the Constructor */
  67656. options: ISpriteMapOptions;
  67657. /** Public Sprite Storage array, parsed from atlasJSON */
  67658. sprites: Array<ISpriteJSONSprite>;
  67659. /** Returns the Number of Sprites in the System */
  67660. get spriteCount(): number;
  67661. /** Returns the Position of Output Plane*/
  67662. get position(): Vector3;
  67663. /** Returns the Position of Output Plane*/
  67664. set position(v: Vector3);
  67665. /** Returns the Rotation of Output Plane*/
  67666. get rotation(): Vector3;
  67667. /** Returns the Rotation of Output Plane*/
  67668. set rotation(v: Vector3);
  67669. /** Sets the AnimationMap*/
  67670. get animationMap(): RawTexture;
  67671. /** Sets the AnimationMap*/
  67672. set animationMap(v: RawTexture);
  67673. /** Scene that the SpriteMap was created in */
  67674. private _scene;
  67675. /** Texture Buffer of Float32 that holds tile frame data*/
  67676. private _frameMap;
  67677. /** Texture Buffers of Float32 that holds tileMap data*/
  67678. private _tileMaps;
  67679. /** Texture Buffer of Float32 that holds Animation Data*/
  67680. private _animationMap;
  67681. /** Custom ShaderMaterial Central to the System*/
  67682. private _material;
  67683. /** Custom ShaderMaterial Central to the System*/
  67684. private _output;
  67685. /** Systems Time Ticker*/
  67686. private _time;
  67687. /**
  67688. * Creates a new SpriteMap
  67689. * @param name defines the SpriteMaps Name
  67690. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67691. * @param spriteSheet is the Texture that the Sprites are on.
  67692. * @param options a basic deployment configuration
  67693. * @param scene The Scene that the map is deployed on
  67694. */
  67695. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67696. /**
  67697. * Returns tileID location
  67698. * @returns Vector2 the cell position ID
  67699. */
  67700. getTileID(): Vector2;
  67701. /**
  67702. * Gets the UV location of the mouse over the SpriteMap.
  67703. * @returns Vector2 the UV position of the mouse interaction
  67704. */
  67705. getMousePosition(): Vector2;
  67706. /**
  67707. * Creates the "frame" texture Buffer
  67708. * -------------------------------------
  67709. * Structure of frames
  67710. * "filename": "Falling-Water-2.png",
  67711. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67712. * "rotated": true,
  67713. * "trimmed": true,
  67714. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67715. * "sourceSize": {"w":32,"h":32}
  67716. * @returns RawTexture of the frameMap
  67717. */
  67718. private _createFrameBuffer;
  67719. /**
  67720. * Creates the tileMap texture Buffer
  67721. * @param buffer normally and array of numbers, or a false to generate from scratch
  67722. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67723. * @returns RawTexture of the tileMap
  67724. */
  67725. private _createTileBuffer;
  67726. /**
  67727. * Modifies the data of the tileMaps
  67728. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67729. * @param pos is the iVector2 Coordinates of the Tile
  67730. * @param tile The SpriteIndex of the new Tile
  67731. */
  67732. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67733. /**
  67734. * Creates the animationMap texture Buffer
  67735. * @param buffer normally and array of numbers, or a false to generate from scratch
  67736. * @returns RawTexture of the animationMap
  67737. */
  67738. private _createTileAnimationBuffer;
  67739. /**
  67740. * Modifies the data of the animationMap
  67741. * @param cellID is the Index of the Sprite
  67742. * @param _frame is the target Animation frame
  67743. * @param toCell is the Target Index of the next frame of the animation
  67744. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67745. * @param speed is a global scalar of the time variable on the map.
  67746. */
  67747. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67748. /**
  67749. * Exports the .tilemaps file
  67750. */
  67751. saveTileMaps(): void;
  67752. /**
  67753. * Imports the .tilemaps file
  67754. * @param url of the .tilemaps file
  67755. */
  67756. loadTileMaps(url: string): void;
  67757. /**
  67758. * Release associated resources
  67759. */
  67760. dispose(): void;
  67761. }
  67762. }
  67763. declare module BABYLON {
  67764. /**
  67765. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67766. * @see http://doc.babylonjs.com/babylon101/sprites
  67767. */
  67768. export class SpritePackedManager extends SpriteManager {
  67769. /** defines the packed manager's name */
  67770. name: string;
  67771. /**
  67772. * Creates a new sprite manager from a packed sprite sheet
  67773. * @param name defines the manager's name
  67774. * @param imgUrl defines the sprite sheet url
  67775. * @param capacity defines the maximum allowed number of sprites
  67776. * @param scene defines the hosting scene
  67777. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67778. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67779. * @param samplingMode defines the smapling mode to use with spritesheet
  67780. * @param fromPacked set to true; do not alter
  67781. */
  67782. constructor(
  67783. /** defines the packed manager's name */
  67784. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67785. }
  67786. }
  67787. declare module BABYLON {
  67788. /**
  67789. * Defines the list of states available for a task inside a AssetsManager
  67790. */
  67791. export enum AssetTaskState {
  67792. /**
  67793. * Initialization
  67794. */
  67795. INIT = 0,
  67796. /**
  67797. * Running
  67798. */
  67799. RUNNING = 1,
  67800. /**
  67801. * Done
  67802. */
  67803. DONE = 2,
  67804. /**
  67805. * Error
  67806. */
  67807. ERROR = 3
  67808. }
  67809. /**
  67810. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67811. */
  67812. export abstract class AbstractAssetTask {
  67813. /**
  67814. * Task name
  67815. */ name: string;
  67816. /**
  67817. * Callback called when the task is successful
  67818. */
  67819. onSuccess: (task: any) => void;
  67820. /**
  67821. * Callback called when the task is not successful
  67822. */
  67823. onError: (task: any, message?: string, exception?: any) => void;
  67824. /**
  67825. * Creates a new AssetsManager
  67826. * @param name defines the name of the task
  67827. */
  67828. constructor(
  67829. /**
  67830. * Task name
  67831. */ name: string);
  67832. private _isCompleted;
  67833. private _taskState;
  67834. private _errorObject;
  67835. /**
  67836. * Get if the task is completed
  67837. */
  67838. get isCompleted(): boolean;
  67839. /**
  67840. * Gets the current state of the task
  67841. */
  67842. get taskState(): AssetTaskState;
  67843. /**
  67844. * Gets the current error object (if task is in error)
  67845. */
  67846. get errorObject(): {
  67847. message?: string;
  67848. exception?: any;
  67849. };
  67850. /**
  67851. * Internal only
  67852. * @hidden
  67853. */
  67854. _setErrorObject(message?: string, exception?: any): void;
  67855. /**
  67856. * Execute the current task
  67857. * @param scene defines the scene where you want your assets to be loaded
  67858. * @param onSuccess is a callback called when the task is successfully executed
  67859. * @param onError is a callback called if an error occurs
  67860. */
  67861. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67862. /**
  67863. * Execute the current task
  67864. * @param scene defines the scene where you want your assets to be loaded
  67865. * @param onSuccess is a callback called when the task is successfully executed
  67866. * @param onError is a callback called if an error occurs
  67867. */
  67868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67869. /**
  67870. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67871. * This can be used with failed tasks that have the reason for failure fixed.
  67872. */
  67873. reset(): void;
  67874. private onErrorCallback;
  67875. private onDoneCallback;
  67876. }
  67877. /**
  67878. * Define the interface used by progress events raised during assets loading
  67879. */
  67880. export interface IAssetsProgressEvent {
  67881. /**
  67882. * Defines the number of remaining tasks to process
  67883. */
  67884. remainingCount: number;
  67885. /**
  67886. * Defines the total number of tasks
  67887. */
  67888. totalCount: number;
  67889. /**
  67890. * Defines the task that was just processed
  67891. */
  67892. task: AbstractAssetTask;
  67893. }
  67894. /**
  67895. * Class used to share progress information about assets loading
  67896. */
  67897. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67898. /**
  67899. * Defines the number of remaining tasks to process
  67900. */
  67901. remainingCount: number;
  67902. /**
  67903. * Defines the total number of tasks
  67904. */
  67905. totalCount: number;
  67906. /**
  67907. * Defines the task that was just processed
  67908. */
  67909. task: AbstractAssetTask;
  67910. /**
  67911. * Creates a AssetsProgressEvent
  67912. * @param remainingCount defines the number of remaining tasks to process
  67913. * @param totalCount defines the total number of tasks
  67914. * @param task defines the task that was just processed
  67915. */
  67916. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67917. }
  67918. /**
  67919. * Define a task used by AssetsManager to load meshes
  67920. */
  67921. export class MeshAssetTask extends AbstractAssetTask {
  67922. /**
  67923. * Defines the name of the task
  67924. */
  67925. name: string;
  67926. /**
  67927. * Defines the list of mesh's names you want to load
  67928. */
  67929. meshesNames: any;
  67930. /**
  67931. * Defines the root url to use as a base to load your meshes and associated resources
  67932. */
  67933. rootUrl: string;
  67934. /**
  67935. * Defines the filename of the scene to load from
  67936. */
  67937. sceneFilename: string;
  67938. /**
  67939. * Gets the list of loaded meshes
  67940. */
  67941. loadedMeshes: Array<AbstractMesh>;
  67942. /**
  67943. * Gets the list of loaded particle systems
  67944. */
  67945. loadedParticleSystems: Array<IParticleSystem>;
  67946. /**
  67947. * Gets the list of loaded skeletons
  67948. */
  67949. loadedSkeletons: Array<Skeleton>;
  67950. /**
  67951. * Gets the list of loaded animation groups
  67952. */
  67953. loadedAnimationGroups: Array<AnimationGroup>;
  67954. /**
  67955. * Callback called when the task is successful
  67956. */
  67957. onSuccess: (task: MeshAssetTask) => void;
  67958. /**
  67959. * Callback called when the task is successful
  67960. */
  67961. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67962. /**
  67963. * Creates a new MeshAssetTask
  67964. * @param name defines the name of the task
  67965. * @param meshesNames defines the list of mesh's names you want to load
  67966. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67967. * @param sceneFilename defines the filename of the scene to load from
  67968. */
  67969. constructor(
  67970. /**
  67971. * Defines the name of the task
  67972. */
  67973. name: string,
  67974. /**
  67975. * Defines the list of mesh's names you want to load
  67976. */
  67977. meshesNames: any,
  67978. /**
  67979. * Defines the root url to use as a base to load your meshes and associated resources
  67980. */
  67981. rootUrl: string,
  67982. /**
  67983. * Defines the filename of the scene to load from
  67984. */
  67985. sceneFilename: string);
  67986. /**
  67987. * Execute the current task
  67988. * @param scene defines the scene where you want your assets to be loaded
  67989. * @param onSuccess is a callback called when the task is successfully executed
  67990. * @param onError is a callback called if an error occurs
  67991. */
  67992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67993. }
  67994. /**
  67995. * Define a task used by AssetsManager to load text content
  67996. */
  67997. export class TextFileAssetTask extends AbstractAssetTask {
  67998. /**
  67999. * Defines the name of the task
  68000. */
  68001. name: string;
  68002. /**
  68003. * Defines the location of the file to load
  68004. */
  68005. url: string;
  68006. /**
  68007. * Gets the loaded text string
  68008. */
  68009. text: string;
  68010. /**
  68011. * Callback called when the task is successful
  68012. */
  68013. onSuccess: (task: TextFileAssetTask) => void;
  68014. /**
  68015. * Callback called when the task is successful
  68016. */
  68017. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68018. /**
  68019. * Creates a new TextFileAssetTask object
  68020. * @param name defines the name of the task
  68021. * @param url defines the location of the file to load
  68022. */
  68023. constructor(
  68024. /**
  68025. * Defines the name of the task
  68026. */
  68027. name: string,
  68028. /**
  68029. * Defines the location of the file to load
  68030. */
  68031. url: string);
  68032. /**
  68033. * Execute the current task
  68034. * @param scene defines the scene where you want your assets to be loaded
  68035. * @param onSuccess is a callback called when the task is successfully executed
  68036. * @param onError is a callback called if an error occurs
  68037. */
  68038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68039. }
  68040. /**
  68041. * Define a task used by AssetsManager to load binary data
  68042. */
  68043. export class BinaryFileAssetTask extends AbstractAssetTask {
  68044. /**
  68045. * Defines the name of the task
  68046. */
  68047. name: string;
  68048. /**
  68049. * Defines the location of the file to load
  68050. */
  68051. url: string;
  68052. /**
  68053. * Gets the lodaded data (as an array buffer)
  68054. */
  68055. data: ArrayBuffer;
  68056. /**
  68057. * Callback called when the task is successful
  68058. */
  68059. onSuccess: (task: BinaryFileAssetTask) => void;
  68060. /**
  68061. * Callback called when the task is successful
  68062. */
  68063. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68064. /**
  68065. * Creates a new BinaryFileAssetTask object
  68066. * @param name defines the name of the new task
  68067. * @param url defines the location of the file to load
  68068. */
  68069. constructor(
  68070. /**
  68071. * Defines the name of the task
  68072. */
  68073. name: string,
  68074. /**
  68075. * Defines the location of the file to load
  68076. */
  68077. url: string);
  68078. /**
  68079. * Execute the current task
  68080. * @param scene defines the scene where you want your assets to be loaded
  68081. * @param onSuccess is a callback called when the task is successfully executed
  68082. * @param onError is a callback called if an error occurs
  68083. */
  68084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68085. }
  68086. /**
  68087. * Define a task used by AssetsManager to load images
  68088. */
  68089. export class ImageAssetTask extends AbstractAssetTask {
  68090. /**
  68091. * Defines the name of the task
  68092. */
  68093. name: string;
  68094. /**
  68095. * Defines the location of the image to load
  68096. */
  68097. url: string;
  68098. /**
  68099. * Gets the loaded images
  68100. */
  68101. image: HTMLImageElement;
  68102. /**
  68103. * Callback called when the task is successful
  68104. */
  68105. onSuccess: (task: ImageAssetTask) => void;
  68106. /**
  68107. * Callback called when the task is successful
  68108. */
  68109. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68110. /**
  68111. * Creates a new ImageAssetTask
  68112. * @param name defines the name of the task
  68113. * @param url defines the location of the image to load
  68114. */
  68115. constructor(
  68116. /**
  68117. * Defines the name of the task
  68118. */
  68119. name: string,
  68120. /**
  68121. * Defines the location of the image to load
  68122. */
  68123. url: string);
  68124. /**
  68125. * Execute the current task
  68126. * @param scene defines the scene where you want your assets to be loaded
  68127. * @param onSuccess is a callback called when the task is successfully executed
  68128. * @param onError is a callback called if an error occurs
  68129. */
  68130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68131. }
  68132. /**
  68133. * Defines the interface used by texture loading tasks
  68134. */
  68135. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68136. /**
  68137. * Gets the loaded texture
  68138. */
  68139. texture: TEX;
  68140. }
  68141. /**
  68142. * Define a task used by AssetsManager to load 2D textures
  68143. */
  68144. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68145. /**
  68146. * Defines the name of the task
  68147. */
  68148. name: string;
  68149. /**
  68150. * Defines the location of the file to load
  68151. */
  68152. url: string;
  68153. /**
  68154. * Defines if mipmap should not be generated (default is false)
  68155. */
  68156. noMipmap?: boolean | undefined;
  68157. /**
  68158. * Defines if texture must be inverted on Y axis (default is true)
  68159. */
  68160. invertY: boolean;
  68161. /**
  68162. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68163. */
  68164. samplingMode: number;
  68165. /**
  68166. * Gets the loaded texture
  68167. */
  68168. texture: Texture;
  68169. /**
  68170. * Callback called when the task is successful
  68171. */
  68172. onSuccess: (task: TextureAssetTask) => void;
  68173. /**
  68174. * Callback called when the task is successful
  68175. */
  68176. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68177. /**
  68178. * Creates a new TextureAssetTask object
  68179. * @param name defines the name of the task
  68180. * @param url defines the location of the file to load
  68181. * @param noMipmap defines if mipmap should not be generated (default is false)
  68182. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68183. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68184. */
  68185. constructor(
  68186. /**
  68187. * Defines the name of the task
  68188. */
  68189. name: string,
  68190. /**
  68191. * Defines the location of the file to load
  68192. */
  68193. url: string,
  68194. /**
  68195. * Defines if mipmap should not be generated (default is false)
  68196. */
  68197. noMipmap?: boolean | undefined,
  68198. /**
  68199. * Defines if texture must be inverted on Y axis (default is true)
  68200. */
  68201. invertY?: boolean,
  68202. /**
  68203. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68204. */
  68205. samplingMode?: number);
  68206. /**
  68207. * Execute the current task
  68208. * @param scene defines the scene where you want your assets to be loaded
  68209. * @param onSuccess is a callback called when the task is successfully executed
  68210. * @param onError is a callback called if an error occurs
  68211. */
  68212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68213. }
  68214. /**
  68215. * Define a task used by AssetsManager to load cube textures
  68216. */
  68217. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68218. /**
  68219. * Defines the name of the task
  68220. */
  68221. name: string;
  68222. /**
  68223. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68224. */
  68225. url: string;
  68226. /**
  68227. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68228. */
  68229. extensions?: string[] | undefined;
  68230. /**
  68231. * Defines if mipmaps should not be generated (default is false)
  68232. */
  68233. noMipmap?: boolean | undefined;
  68234. /**
  68235. * Defines the explicit list of files (undefined by default)
  68236. */
  68237. files?: string[] | undefined;
  68238. /**
  68239. * Gets the loaded texture
  68240. */
  68241. texture: CubeTexture;
  68242. /**
  68243. * Callback called when the task is successful
  68244. */
  68245. onSuccess: (task: CubeTextureAssetTask) => void;
  68246. /**
  68247. * Callback called when the task is successful
  68248. */
  68249. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68250. /**
  68251. * Creates a new CubeTextureAssetTask
  68252. * @param name defines the name of the task
  68253. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68254. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68255. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68256. * @param files defines the explicit list of files (undefined by default)
  68257. */
  68258. constructor(
  68259. /**
  68260. * Defines the name of the task
  68261. */
  68262. name: string,
  68263. /**
  68264. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68265. */
  68266. url: string,
  68267. /**
  68268. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68269. */
  68270. extensions?: string[] | undefined,
  68271. /**
  68272. * Defines if mipmaps should not be generated (default is false)
  68273. */
  68274. noMipmap?: boolean | undefined,
  68275. /**
  68276. * Defines the explicit list of files (undefined by default)
  68277. */
  68278. files?: string[] | undefined);
  68279. /**
  68280. * Execute the current task
  68281. * @param scene defines the scene where you want your assets to be loaded
  68282. * @param onSuccess is a callback called when the task is successfully executed
  68283. * @param onError is a callback called if an error occurs
  68284. */
  68285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68286. }
  68287. /**
  68288. * Define a task used by AssetsManager to load HDR cube textures
  68289. */
  68290. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68291. /**
  68292. * Defines the name of the task
  68293. */
  68294. name: string;
  68295. /**
  68296. * Defines the location of the file to load
  68297. */
  68298. url: string;
  68299. /**
  68300. * Defines the desired size (the more it increases the longer the generation will be)
  68301. */
  68302. size: number;
  68303. /**
  68304. * Defines if mipmaps should not be generated (default is false)
  68305. */
  68306. noMipmap: boolean;
  68307. /**
  68308. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68309. */
  68310. generateHarmonics: boolean;
  68311. /**
  68312. * 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)
  68313. */
  68314. gammaSpace: boolean;
  68315. /**
  68316. * Internal Use Only
  68317. */
  68318. reserved: boolean;
  68319. /**
  68320. * Gets the loaded texture
  68321. */
  68322. texture: HDRCubeTexture;
  68323. /**
  68324. * Callback called when the task is successful
  68325. */
  68326. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68327. /**
  68328. * Callback called when the task is successful
  68329. */
  68330. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68331. /**
  68332. * Creates a new HDRCubeTextureAssetTask object
  68333. * @param name defines the name of the task
  68334. * @param url defines the location of the file to load
  68335. * @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.
  68336. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68337. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68338. * @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)
  68339. * @param reserved Internal use only
  68340. */
  68341. constructor(
  68342. /**
  68343. * Defines the name of the task
  68344. */
  68345. name: string,
  68346. /**
  68347. * Defines the location of the file to load
  68348. */
  68349. url: string,
  68350. /**
  68351. * Defines the desired size (the more it increases the longer the generation will be)
  68352. */
  68353. size: number,
  68354. /**
  68355. * Defines if mipmaps should not be generated (default is false)
  68356. */
  68357. noMipmap?: boolean,
  68358. /**
  68359. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68360. */
  68361. generateHarmonics?: boolean,
  68362. /**
  68363. * 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)
  68364. */
  68365. gammaSpace?: boolean,
  68366. /**
  68367. * Internal Use Only
  68368. */
  68369. reserved?: boolean);
  68370. /**
  68371. * Execute the current task
  68372. * @param scene defines the scene where you want your assets to be loaded
  68373. * @param onSuccess is a callback called when the task is successfully executed
  68374. * @param onError is a callback called if an error occurs
  68375. */
  68376. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68377. }
  68378. /**
  68379. * Define a task used by AssetsManager to load Equirectangular cube textures
  68380. */
  68381. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68382. /**
  68383. * Defines the name of the task
  68384. */
  68385. name: string;
  68386. /**
  68387. * Defines the location of the file to load
  68388. */
  68389. url: string;
  68390. /**
  68391. * Defines the desired size (the more it increases the longer the generation will be)
  68392. */
  68393. size: number;
  68394. /**
  68395. * Defines if mipmaps should not be generated (default is false)
  68396. */
  68397. noMipmap: boolean;
  68398. /**
  68399. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68400. * but the standard material would require them in Gamma space) (default is true)
  68401. */
  68402. gammaSpace: boolean;
  68403. /**
  68404. * Gets the loaded texture
  68405. */
  68406. texture: EquiRectangularCubeTexture;
  68407. /**
  68408. * Callback called when the task is successful
  68409. */
  68410. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68411. /**
  68412. * Callback called when the task is successful
  68413. */
  68414. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68415. /**
  68416. * Creates a new EquiRectangularCubeTextureAssetTask object
  68417. * @param name defines the name of the task
  68418. * @param url defines the location of the file to load
  68419. * @param size defines the desired size (the more it increases the longer the generation will be)
  68420. * If the size is omitted this implies you are using a preprocessed cubemap.
  68421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68422. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68423. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68424. * (default is true)
  68425. */
  68426. constructor(
  68427. /**
  68428. * Defines the name of the task
  68429. */
  68430. name: string,
  68431. /**
  68432. * Defines the location of the file to load
  68433. */
  68434. url: string,
  68435. /**
  68436. * Defines the desired size (the more it increases the longer the generation will be)
  68437. */
  68438. size: number,
  68439. /**
  68440. * Defines if mipmaps should not be generated (default is false)
  68441. */
  68442. noMipmap?: boolean,
  68443. /**
  68444. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68445. * but the standard material would require them in Gamma space) (default is true)
  68446. */
  68447. gammaSpace?: boolean);
  68448. /**
  68449. * Execute the current task
  68450. * @param scene defines the scene where you want your assets to be loaded
  68451. * @param onSuccess is a callback called when the task is successfully executed
  68452. * @param onError is a callback called if an error occurs
  68453. */
  68454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68455. }
  68456. /**
  68457. * This class can be used to easily import assets into a scene
  68458. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68459. */
  68460. export class AssetsManager {
  68461. private _scene;
  68462. private _isLoading;
  68463. protected _tasks: AbstractAssetTask[];
  68464. protected _waitingTasksCount: number;
  68465. protected _totalTasksCount: number;
  68466. /**
  68467. * Callback called when all tasks are processed
  68468. */
  68469. onFinish: (tasks: AbstractAssetTask[]) => void;
  68470. /**
  68471. * Callback called when a task is successful
  68472. */
  68473. onTaskSuccess: (task: AbstractAssetTask) => void;
  68474. /**
  68475. * Callback called when a task had an error
  68476. */
  68477. onTaskError: (task: AbstractAssetTask) => void;
  68478. /**
  68479. * Callback called when a task is done (whatever the result is)
  68480. */
  68481. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68482. /**
  68483. * Observable called when all tasks are processed
  68484. */
  68485. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68486. /**
  68487. * Observable called when a task had an error
  68488. */
  68489. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68490. /**
  68491. * Observable called when all tasks were executed
  68492. */
  68493. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68494. /**
  68495. * Observable called when a task is done (whatever the result is)
  68496. */
  68497. onProgressObservable: Observable<IAssetsProgressEvent>;
  68498. /**
  68499. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68501. */
  68502. useDefaultLoadingScreen: boolean;
  68503. /**
  68504. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68505. * when all assets have been downloaded.
  68506. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68507. */
  68508. autoHideLoadingUI: boolean;
  68509. /**
  68510. * Creates a new AssetsManager
  68511. * @param scene defines the scene to work on
  68512. */
  68513. constructor(scene: Scene);
  68514. /**
  68515. * Add a MeshAssetTask to the list of active tasks
  68516. * @param taskName defines the name of the new task
  68517. * @param meshesNames defines the name of meshes to load
  68518. * @param rootUrl defines the root url to use to locate files
  68519. * @param sceneFilename defines the filename of the scene file
  68520. * @returns a new MeshAssetTask object
  68521. */
  68522. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68523. /**
  68524. * Add a TextFileAssetTask to the list of active tasks
  68525. * @param taskName defines the name of the new task
  68526. * @param url defines the url of the file to load
  68527. * @returns a new TextFileAssetTask object
  68528. */
  68529. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68530. /**
  68531. * Add a BinaryFileAssetTask to the list of active tasks
  68532. * @param taskName defines the name of the new task
  68533. * @param url defines the url of the file to load
  68534. * @returns a new BinaryFileAssetTask object
  68535. */
  68536. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68537. /**
  68538. * Add a ImageAssetTask to the list of active tasks
  68539. * @param taskName defines the name of the new task
  68540. * @param url defines the url of the file to load
  68541. * @returns a new ImageAssetTask object
  68542. */
  68543. addImageTask(taskName: string, url: string): ImageAssetTask;
  68544. /**
  68545. * Add a TextureAssetTask to the list of active tasks
  68546. * @param taskName defines the name of the new task
  68547. * @param url defines the url of the file to load
  68548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68549. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68550. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68551. * @returns a new TextureAssetTask object
  68552. */
  68553. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68554. /**
  68555. * Add a CubeTextureAssetTask to the list of active tasks
  68556. * @param taskName defines the name of the new task
  68557. * @param url defines the url of the file to load
  68558. * @param extensions defines the extension to use to load the cube map (can be null)
  68559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68560. * @param files defines the list of files to load (can be null)
  68561. * @returns a new CubeTextureAssetTask object
  68562. */
  68563. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68564. /**
  68565. *
  68566. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68567. * @param taskName defines the name of the new task
  68568. * @param url defines the url of the file to load
  68569. * @param size defines the size you want for the cubemap (can be null)
  68570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68571. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68572. * @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)
  68573. * @param reserved Internal use only
  68574. * @returns a new HDRCubeTextureAssetTask object
  68575. */
  68576. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68577. /**
  68578. *
  68579. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68580. * @param taskName defines the name of the new task
  68581. * @param url defines the url of the file to load
  68582. * @param size defines the size you want for the cubemap (can be null)
  68583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68584. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68585. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68586. * @returns a new EquiRectangularCubeTextureAssetTask object
  68587. */
  68588. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68589. /**
  68590. * Remove a task from the assets manager.
  68591. * @param task the task to remove
  68592. */
  68593. removeTask(task: AbstractAssetTask): void;
  68594. private _decreaseWaitingTasksCount;
  68595. private _runTask;
  68596. /**
  68597. * Reset the AssetsManager and remove all tasks
  68598. * @return the current instance of the AssetsManager
  68599. */
  68600. reset(): AssetsManager;
  68601. /**
  68602. * Start the loading process
  68603. * @return the current instance of the AssetsManager
  68604. */
  68605. load(): AssetsManager;
  68606. /**
  68607. * Start the loading process as an async operation
  68608. * @return a promise returning the list of failed tasks
  68609. */
  68610. loadAsync(): Promise<void>;
  68611. }
  68612. }
  68613. declare module BABYLON {
  68614. /**
  68615. * Wrapper class for promise with external resolve and reject.
  68616. */
  68617. export class Deferred<T> {
  68618. /**
  68619. * The promise associated with this deferred object.
  68620. */
  68621. readonly promise: Promise<T>;
  68622. private _resolve;
  68623. private _reject;
  68624. /**
  68625. * The resolve method of the promise associated with this deferred object.
  68626. */
  68627. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68628. /**
  68629. * The reject method of the promise associated with this deferred object.
  68630. */
  68631. get reject(): (reason?: any) => void;
  68632. /**
  68633. * Constructor for this deferred object.
  68634. */
  68635. constructor();
  68636. }
  68637. }
  68638. declare module BABYLON {
  68639. /**
  68640. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68641. */
  68642. export class MeshExploder {
  68643. private _centerMesh;
  68644. private _meshes;
  68645. private _meshesOrigins;
  68646. private _toCenterVectors;
  68647. private _scaledDirection;
  68648. private _newPosition;
  68649. private _centerPosition;
  68650. /**
  68651. * Explodes meshes from a center mesh.
  68652. * @param meshes The meshes to explode.
  68653. * @param centerMesh The mesh to be center of explosion.
  68654. */
  68655. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68656. private _setCenterMesh;
  68657. /**
  68658. * Get class name
  68659. * @returns "MeshExploder"
  68660. */
  68661. getClassName(): string;
  68662. /**
  68663. * "Exploded meshes"
  68664. * @returns Array of meshes with the centerMesh at index 0.
  68665. */
  68666. getMeshes(): Array<Mesh>;
  68667. /**
  68668. * Explodes meshes giving a specific direction
  68669. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68670. */
  68671. explode(direction?: number): void;
  68672. }
  68673. }
  68674. declare module BABYLON {
  68675. /**
  68676. * Class used to help managing file picking and drag'n'drop
  68677. */
  68678. export class FilesInput {
  68679. /**
  68680. * List of files ready to be loaded
  68681. */
  68682. static get FilesToLoad(): {
  68683. [key: string]: File;
  68684. };
  68685. /**
  68686. * Callback called when a file is processed
  68687. */
  68688. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68689. private _engine;
  68690. private _currentScene;
  68691. private _sceneLoadedCallback;
  68692. private _progressCallback;
  68693. private _additionalRenderLoopLogicCallback;
  68694. private _textureLoadingCallback;
  68695. private _startingProcessingFilesCallback;
  68696. private _onReloadCallback;
  68697. private _errorCallback;
  68698. private _elementToMonitor;
  68699. private _sceneFileToLoad;
  68700. private _filesToLoad;
  68701. /**
  68702. * Creates a new FilesInput
  68703. * @param engine defines the rendering engine
  68704. * @param scene defines the hosting scene
  68705. * @param sceneLoadedCallback callback called when scene is loaded
  68706. * @param progressCallback callback called to track progress
  68707. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68708. * @param textureLoadingCallback callback called when a texture is loading
  68709. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68710. * @param onReloadCallback callback called when a reload is requested
  68711. * @param errorCallback callback call if an error occurs
  68712. */
  68713. 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);
  68714. private _dragEnterHandler;
  68715. private _dragOverHandler;
  68716. private _dropHandler;
  68717. /**
  68718. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68719. * @param elementToMonitor defines the DOM element to track
  68720. */
  68721. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68722. /**
  68723. * Release all associated resources
  68724. */
  68725. dispose(): void;
  68726. private renderFunction;
  68727. private drag;
  68728. private drop;
  68729. private _traverseFolder;
  68730. private _processFiles;
  68731. /**
  68732. * Load files from a drop event
  68733. * @param event defines the drop event to use as source
  68734. */
  68735. loadFiles(event: any): void;
  68736. private _processReload;
  68737. /**
  68738. * Reload the current scene from the loaded files
  68739. */
  68740. reload(): void;
  68741. }
  68742. }
  68743. declare module BABYLON {
  68744. /**
  68745. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68747. */
  68748. export class SceneOptimization {
  68749. /**
  68750. * Defines the priority of this optimization (0 by default which means first in the list)
  68751. */
  68752. priority: number;
  68753. /**
  68754. * Gets a string describing the action executed by the current optimization
  68755. * @returns description string
  68756. */
  68757. getDescription(): string;
  68758. /**
  68759. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68760. * @param scene defines the current scene where to apply this optimization
  68761. * @param optimizer defines the current optimizer
  68762. * @returns true if everything that can be done was applied
  68763. */
  68764. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68765. /**
  68766. * Creates the SceneOptimization object
  68767. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68768. * @param desc defines the description associated with the optimization
  68769. */
  68770. constructor(
  68771. /**
  68772. * Defines the priority of this optimization (0 by default which means first in the list)
  68773. */
  68774. priority?: number);
  68775. }
  68776. /**
  68777. * Defines an optimization used to reduce the size of render target textures
  68778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68779. */
  68780. export class TextureOptimization extends SceneOptimization {
  68781. /**
  68782. * Defines the priority of this optimization (0 by default which means first in the list)
  68783. */
  68784. priority: number;
  68785. /**
  68786. * 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
  68787. */
  68788. maximumSize: number;
  68789. /**
  68790. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68791. */
  68792. step: number;
  68793. /**
  68794. * Gets a string describing the action executed by the current optimization
  68795. * @returns description string
  68796. */
  68797. getDescription(): string;
  68798. /**
  68799. * Creates the TextureOptimization object
  68800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68801. * @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
  68802. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68803. */
  68804. constructor(
  68805. /**
  68806. * Defines the priority of this optimization (0 by default which means first in the list)
  68807. */
  68808. priority?: number,
  68809. /**
  68810. * 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
  68811. */
  68812. maximumSize?: number,
  68813. /**
  68814. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68815. */
  68816. step?: number);
  68817. /**
  68818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68819. * @param scene defines the current scene where to apply this optimization
  68820. * @param optimizer defines the current optimizer
  68821. * @returns true if everything that can be done was applied
  68822. */
  68823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68824. }
  68825. /**
  68826. * Defines an optimization used to increase or decrease the rendering resolution
  68827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68828. */
  68829. export class HardwareScalingOptimization extends SceneOptimization {
  68830. /**
  68831. * Defines the priority of this optimization (0 by default which means first in the list)
  68832. */
  68833. priority: number;
  68834. /**
  68835. * Defines the maximum scale to use (2 by default)
  68836. */
  68837. maximumScale: number;
  68838. /**
  68839. * Defines the step to use between two passes (0.5 by default)
  68840. */
  68841. step: number;
  68842. private _currentScale;
  68843. private _directionOffset;
  68844. /**
  68845. * Gets a string describing the action executed by the current optimization
  68846. * @return description string
  68847. */
  68848. getDescription(): string;
  68849. /**
  68850. * Creates the HardwareScalingOptimization object
  68851. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68852. * @param maximumScale defines the maximum scale to use (2 by default)
  68853. * @param step defines the step to use between two passes (0.5 by default)
  68854. */
  68855. constructor(
  68856. /**
  68857. * Defines the priority of this optimization (0 by default which means first in the list)
  68858. */
  68859. priority?: number,
  68860. /**
  68861. * Defines the maximum scale to use (2 by default)
  68862. */
  68863. maximumScale?: number,
  68864. /**
  68865. * Defines the step to use between two passes (0.5 by default)
  68866. */
  68867. step?: number);
  68868. /**
  68869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68870. * @param scene defines the current scene where to apply this optimization
  68871. * @param optimizer defines the current optimizer
  68872. * @returns true if everything that can be done was applied
  68873. */
  68874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68875. }
  68876. /**
  68877. * Defines an optimization used to remove shadows
  68878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68879. */
  68880. export class ShadowsOptimization extends SceneOptimization {
  68881. /**
  68882. * Gets a string describing the action executed by the current optimization
  68883. * @return description string
  68884. */
  68885. getDescription(): string;
  68886. /**
  68887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68888. * @param scene defines the current scene where to apply this optimization
  68889. * @param optimizer defines the current optimizer
  68890. * @returns true if everything that can be done was applied
  68891. */
  68892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68893. }
  68894. /**
  68895. * Defines an optimization used to turn post-processes off
  68896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68897. */
  68898. export class PostProcessesOptimization extends SceneOptimization {
  68899. /**
  68900. * Gets a string describing the action executed by the current optimization
  68901. * @return description string
  68902. */
  68903. getDescription(): string;
  68904. /**
  68905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68906. * @param scene defines the current scene where to apply this optimization
  68907. * @param optimizer defines the current optimizer
  68908. * @returns true if everything that can be done was applied
  68909. */
  68910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68911. }
  68912. /**
  68913. * Defines an optimization used to turn lens flares off
  68914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68915. */
  68916. export class LensFlaresOptimization extends SceneOptimization {
  68917. /**
  68918. * Gets a string describing the action executed by the current optimization
  68919. * @return description string
  68920. */
  68921. getDescription(): string;
  68922. /**
  68923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68924. * @param scene defines the current scene where to apply this optimization
  68925. * @param optimizer defines the current optimizer
  68926. * @returns true if everything that can be done was applied
  68927. */
  68928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68929. }
  68930. /**
  68931. * Defines an optimization based on user defined callback.
  68932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68933. */
  68934. export class CustomOptimization extends SceneOptimization {
  68935. /**
  68936. * Callback called to apply the custom optimization.
  68937. */
  68938. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68939. /**
  68940. * Callback called to get custom description
  68941. */
  68942. onGetDescription: () => string;
  68943. /**
  68944. * Gets a string describing the action executed by the current optimization
  68945. * @returns description string
  68946. */
  68947. getDescription(): string;
  68948. /**
  68949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68950. * @param scene defines the current scene where to apply this optimization
  68951. * @param optimizer defines the current optimizer
  68952. * @returns true if everything that can be done was applied
  68953. */
  68954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68955. }
  68956. /**
  68957. * Defines an optimization used to turn particles off
  68958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68959. */
  68960. export class ParticlesOptimization extends SceneOptimization {
  68961. /**
  68962. * Gets a string describing the action executed by the current optimization
  68963. * @return description string
  68964. */
  68965. getDescription(): string;
  68966. /**
  68967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68968. * @param scene defines the current scene where to apply this optimization
  68969. * @param optimizer defines the current optimizer
  68970. * @returns true if everything that can be done was applied
  68971. */
  68972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68973. }
  68974. /**
  68975. * Defines an optimization used to turn render targets off
  68976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68977. */
  68978. export class RenderTargetsOptimization extends SceneOptimization {
  68979. /**
  68980. * Gets a string describing the action executed by the current optimization
  68981. * @return description string
  68982. */
  68983. getDescription(): string;
  68984. /**
  68985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68986. * @param scene defines the current scene where to apply this optimization
  68987. * @param optimizer defines the current optimizer
  68988. * @returns true if everything that can be done was applied
  68989. */
  68990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68991. }
  68992. /**
  68993. * Defines an optimization used to merge meshes with compatible materials
  68994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68995. */
  68996. export class MergeMeshesOptimization extends SceneOptimization {
  68997. private static _UpdateSelectionTree;
  68998. /**
  68999. * Gets or sets a boolean which defines if optimization octree has to be updated
  69000. */
  69001. static get UpdateSelectionTree(): boolean;
  69002. /**
  69003. * Gets or sets a boolean which defines if optimization octree has to be updated
  69004. */
  69005. static set UpdateSelectionTree(value: boolean);
  69006. /**
  69007. * Gets a string describing the action executed by the current optimization
  69008. * @return description string
  69009. */
  69010. getDescription(): string;
  69011. private _canBeMerged;
  69012. /**
  69013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69014. * @param scene defines the current scene where to apply this optimization
  69015. * @param optimizer defines the current optimizer
  69016. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69017. * @returns true if everything that can be done was applied
  69018. */
  69019. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69020. }
  69021. /**
  69022. * Defines a list of options used by SceneOptimizer
  69023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69024. */
  69025. export class SceneOptimizerOptions {
  69026. /**
  69027. * Defines the target frame rate to reach (60 by default)
  69028. */
  69029. targetFrameRate: number;
  69030. /**
  69031. * Defines the interval between two checkes (2000ms by default)
  69032. */
  69033. trackerDuration: number;
  69034. /**
  69035. * Gets the list of optimizations to apply
  69036. */
  69037. optimizations: SceneOptimization[];
  69038. /**
  69039. * Creates a new list of options used by SceneOptimizer
  69040. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69041. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69042. */
  69043. constructor(
  69044. /**
  69045. * Defines the target frame rate to reach (60 by default)
  69046. */
  69047. targetFrameRate?: number,
  69048. /**
  69049. * Defines the interval between two checkes (2000ms by default)
  69050. */
  69051. trackerDuration?: number);
  69052. /**
  69053. * Add a new optimization
  69054. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69055. * @returns the current SceneOptimizerOptions
  69056. */
  69057. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69058. /**
  69059. * Add a new custom optimization
  69060. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69061. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69062. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69063. * @returns the current SceneOptimizerOptions
  69064. */
  69065. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69066. /**
  69067. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69068. * @param targetFrameRate defines the target frame rate (60 by default)
  69069. * @returns a SceneOptimizerOptions object
  69070. */
  69071. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69072. /**
  69073. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69074. * @param targetFrameRate defines the target frame rate (60 by default)
  69075. * @returns a SceneOptimizerOptions object
  69076. */
  69077. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69078. /**
  69079. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69080. * @param targetFrameRate defines the target frame rate (60 by default)
  69081. * @returns a SceneOptimizerOptions object
  69082. */
  69083. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69084. }
  69085. /**
  69086. * Class used to run optimizations in order to reach a target frame rate
  69087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69088. */
  69089. export class SceneOptimizer implements IDisposable {
  69090. private _isRunning;
  69091. private _options;
  69092. private _scene;
  69093. private _currentPriorityLevel;
  69094. private _targetFrameRate;
  69095. private _trackerDuration;
  69096. private _currentFrameRate;
  69097. private _sceneDisposeObserver;
  69098. private _improvementMode;
  69099. /**
  69100. * Defines an observable called when the optimizer reaches the target frame rate
  69101. */
  69102. onSuccessObservable: Observable<SceneOptimizer>;
  69103. /**
  69104. * Defines an observable called when the optimizer enables an optimization
  69105. */
  69106. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69107. /**
  69108. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69109. */
  69110. onFailureObservable: Observable<SceneOptimizer>;
  69111. /**
  69112. * Gets a boolean indicating if the optimizer is in improvement mode
  69113. */
  69114. get isInImprovementMode(): boolean;
  69115. /**
  69116. * Gets the current priority level (0 at start)
  69117. */
  69118. get currentPriorityLevel(): number;
  69119. /**
  69120. * Gets the current frame rate checked by the SceneOptimizer
  69121. */
  69122. get currentFrameRate(): number;
  69123. /**
  69124. * Gets or sets the current target frame rate (60 by default)
  69125. */
  69126. get targetFrameRate(): number;
  69127. /**
  69128. * Gets or sets the current target frame rate (60 by default)
  69129. */
  69130. set targetFrameRate(value: number);
  69131. /**
  69132. * Gets or sets the current interval between two checks (every 2000ms by default)
  69133. */
  69134. get trackerDuration(): number;
  69135. /**
  69136. * Gets or sets the current interval between two checks (every 2000ms by default)
  69137. */
  69138. set trackerDuration(value: number);
  69139. /**
  69140. * Gets the list of active optimizations
  69141. */
  69142. get optimizations(): SceneOptimization[];
  69143. /**
  69144. * Creates a new SceneOptimizer
  69145. * @param scene defines the scene to work on
  69146. * @param options defines the options to use with the SceneOptimizer
  69147. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69148. * @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)
  69149. */
  69150. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69151. /**
  69152. * Stops the current optimizer
  69153. */
  69154. stop(): void;
  69155. /**
  69156. * Reset the optimizer to initial step (current priority level = 0)
  69157. */
  69158. reset(): void;
  69159. /**
  69160. * Start the optimizer. By default it will try to reach a specific framerate
  69161. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69162. */
  69163. start(): void;
  69164. private _checkCurrentState;
  69165. /**
  69166. * Release all resources
  69167. */
  69168. dispose(): void;
  69169. /**
  69170. * Helper function to create a SceneOptimizer with one single line of code
  69171. * @param scene defines the scene to work on
  69172. * @param options defines the options to use with the SceneOptimizer
  69173. * @param onSuccess defines a callback to call on success
  69174. * @param onFailure defines a callback to call on failure
  69175. * @returns the new SceneOptimizer object
  69176. */
  69177. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69178. }
  69179. }
  69180. declare module BABYLON {
  69181. /**
  69182. * Class used to serialize a scene into a string
  69183. */
  69184. export class SceneSerializer {
  69185. /**
  69186. * Clear cache used by a previous serialization
  69187. */
  69188. static ClearCache(): void;
  69189. /**
  69190. * Serialize a scene into a JSON compatible object
  69191. * @param scene defines the scene to serialize
  69192. * @returns a JSON compatible object
  69193. */
  69194. static Serialize(scene: Scene): any;
  69195. /**
  69196. * Serialize a mesh into a JSON compatible object
  69197. * @param toSerialize defines the mesh to serialize
  69198. * @param withParents defines if parents must be serialized as well
  69199. * @param withChildren defines if children must be serialized as well
  69200. * @returns a JSON compatible object
  69201. */
  69202. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69203. }
  69204. }
  69205. declare module BABYLON {
  69206. /**
  69207. * Class used to host texture specific utilities
  69208. */
  69209. export class TextureTools {
  69210. /**
  69211. * Uses the GPU to create a copy texture rescaled at a given size
  69212. * @param texture Texture to copy from
  69213. * @param width defines the desired width
  69214. * @param height defines the desired height
  69215. * @param useBilinearMode defines if bilinear mode has to be used
  69216. * @return the generated texture
  69217. */
  69218. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69219. }
  69220. }
  69221. declare module BABYLON {
  69222. /**
  69223. * This represents the different options available for the video capture.
  69224. */
  69225. export interface VideoRecorderOptions {
  69226. /** Defines the mime type of the video. */
  69227. mimeType: string;
  69228. /** Defines the FPS the video should be recorded at. */
  69229. fps: number;
  69230. /** Defines the chunk size for the recording data. */
  69231. recordChunckSize: number;
  69232. /** The audio tracks to attach to the recording. */
  69233. audioTracks?: MediaStreamTrack[];
  69234. }
  69235. /**
  69236. * This can help with recording videos from BabylonJS.
  69237. * This is based on the available WebRTC functionalities of the browser.
  69238. *
  69239. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69240. */
  69241. export class VideoRecorder {
  69242. private static readonly _defaultOptions;
  69243. /**
  69244. * Returns whether or not the VideoRecorder is available in your browser.
  69245. * @param engine Defines the Babylon Engine.
  69246. * @returns true if supported otherwise false.
  69247. */
  69248. static IsSupported(engine: Engine): boolean;
  69249. private readonly _options;
  69250. private _canvas;
  69251. private _mediaRecorder;
  69252. private _recordedChunks;
  69253. private _fileName;
  69254. private _resolve;
  69255. private _reject;
  69256. /**
  69257. * True when a recording is already in progress.
  69258. */
  69259. get isRecording(): boolean;
  69260. /**
  69261. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69262. * @param engine Defines the BabylonJS Engine you wish to record.
  69263. * @param options Defines options that can be used to customize the capture.
  69264. */
  69265. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69266. /**
  69267. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69268. */
  69269. stopRecording(): void;
  69270. /**
  69271. * Starts recording the canvas for a max duration specified in parameters.
  69272. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69273. * If null no automatic download will start and you can rely on the promise to get the data back.
  69274. * @param maxDuration Defines the maximum recording time in seconds.
  69275. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69276. * @return A promise callback at the end of the recording with the video data in Blob.
  69277. */
  69278. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69279. /**
  69280. * Releases internal resources used during the recording.
  69281. */
  69282. dispose(): void;
  69283. private _handleDataAvailable;
  69284. private _handleError;
  69285. private _handleStop;
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /**
  69290. * Class containing a set of static utilities functions for screenshots
  69291. */
  69292. export class ScreenshotTools {
  69293. /**
  69294. * Captures a screenshot of the current rendering
  69295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69296. * @param engine defines the rendering engine
  69297. * @param camera defines the source camera
  69298. * @param size This parameter can be set to a single number or to an object with the
  69299. * following (optional) properties: precision, width, height. If a single number is passed,
  69300. * it will be used for both width and height. If an object is passed, the screenshot size
  69301. * will be derived from the parameters. The precision property is a multiplier allowing
  69302. * rendering at a higher or lower resolution
  69303. * @param successCallback defines the callback receives a single parameter which contains the
  69304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69305. * src parameter of an <img> to display it
  69306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69307. * Check your browser for supported MIME types
  69308. */
  69309. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69310. /**
  69311. * Captures a screenshot of the current rendering
  69312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69313. * @param engine defines the rendering engine
  69314. * @param camera defines the source camera
  69315. * @param size This parameter can be set to a single number or to an object with the
  69316. * following (optional) properties: precision, width, height. If a single number is passed,
  69317. * it will be used for both width and height. If an object is passed, the screenshot size
  69318. * will be derived from the parameters. The precision property is a multiplier allowing
  69319. * rendering at a higher or lower resolution
  69320. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69321. * Check your browser for supported MIME types
  69322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69323. * to the src parameter of an <img> to display it
  69324. */
  69325. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69326. /**
  69327. * Generates an image screenshot from the specified camera.
  69328. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69329. * @param engine The engine to use for rendering
  69330. * @param camera The camera to use for rendering
  69331. * @param size This parameter can be set to a single number or to an object with the
  69332. * following (optional) properties: precision, width, height. If a single number is passed,
  69333. * it will be used for both width and height. If an object is passed, the screenshot size
  69334. * will be derived from the parameters. The precision property is a multiplier allowing
  69335. * rendering at a higher or lower resolution
  69336. * @param successCallback The callback receives a single parameter which contains the
  69337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69338. * src parameter of an <img> to display it
  69339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69340. * Check your browser for supported MIME types
  69341. * @param samples Texture samples (default: 1)
  69342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69343. * @param fileName A name for for the downloaded file.
  69344. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69345. */
  69346. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69347. /**
  69348. * Generates an image screenshot from the specified camera.
  69349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69350. * @param engine The engine to use for rendering
  69351. * @param camera The camera to use for rendering
  69352. * @param size This parameter can be set to a single number or to an object with the
  69353. * following (optional) properties: precision, width, height. If a single number is passed,
  69354. * it will be used for both width and height. If an object is passed, the screenshot size
  69355. * will be derived from the parameters. The precision property is a multiplier allowing
  69356. * rendering at a higher or lower resolution
  69357. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69358. * Check your browser for supported MIME types
  69359. * @param samples Texture samples (default: 1)
  69360. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69361. * @param fileName A name for for the downloaded file.
  69362. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69363. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69364. * to the src parameter of an <img> to display it
  69365. */
  69366. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69367. /**
  69368. * Gets height and width for screenshot size
  69369. * @private
  69370. */
  69371. private static _getScreenshotSize;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /**
  69376. * Interface for a data buffer
  69377. */
  69378. export interface IDataBuffer {
  69379. /**
  69380. * Reads bytes from the data buffer.
  69381. * @param byteOffset The byte offset to read
  69382. * @param byteLength The byte length to read
  69383. * @returns A promise that resolves when the bytes are read
  69384. */
  69385. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69386. /**
  69387. * The byte length of the buffer.
  69388. */
  69389. readonly byteLength: number;
  69390. }
  69391. /**
  69392. * Utility class for reading from a data buffer
  69393. */
  69394. export class DataReader {
  69395. /**
  69396. * The data buffer associated with this data reader.
  69397. */
  69398. readonly buffer: IDataBuffer;
  69399. /**
  69400. * The current byte offset from the beginning of the data buffer.
  69401. */
  69402. byteOffset: number;
  69403. private _dataView;
  69404. private _dataByteOffset;
  69405. /**
  69406. * Constructor
  69407. * @param buffer The buffer to read
  69408. */
  69409. constructor(buffer: IDataBuffer);
  69410. /**
  69411. * Loads the given byte length.
  69412. * @param byteLength The byte length to load
  69413. * @returns A promise that resolves when the load is complete
  69414. */
  69415. loadAsync(byteLength: number): Promise<void>;
  69416. /**
  69417. * Read a unsigned 32-bit integer from the currently loaded data range.
  69418. * @returns The 32-bit integer read
  69419. */
  69420. readUint32(): number;
  69421. /**
  69422. * Read a byte array from the currently loaded data range.
  69423. * @param byteLength The byte length to read
  69424. * @returns The byte array read
  69425. */
  69426. readUint8Array(byteLength: number): Uint8Array;
  69427. /**
  69428. * Read a string from the currently loaded data range.
  69429. * @param byteLength The byte length to read
  69430. * @returns The string read
  69431. */
  69432. readString(byteLength: number): string;
  69433. /**
  69434. * Skips the given byte length the currently loaded data range.
  69435. * @param byteLength The byte length to skip
  69436. */
  69437. skipBytes(byteLength: number): void;
  69438. }
  69439. }
  69440. declare module BABYLON {
  69441. /**
  69442. * Class for storing data to local storage if available or in-memory storage otherwise
  69443. */
  69444. export class DataStorage {
  69445. private static _Storage;
  69446. private static _GetStorage;
  69447. /**
  69448. * Reads a string from the data storage
  69449. * @param key The key to read
  69450. * @param defaultValue The value if the key doesn't exist
  69451. * @returns The string value
  69452. */
  69453. static ReadString(key: string, defaultValue: string): string;
  69454. /**
  69455. * Writes a string to the data storage
  69456. * @param key The key to write
  69457. * @param value The value to write
  69458. */
  69459. static WriteString(key: string, value: string): void;
  69460. /**
  69461. * Reads a boolean from the data storage
  69462. * @param key The key to read
  69463. * @param defaultValue The value if the key doesn't exist
  69464. * @returns The boolean value
  69465. */
  69466. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69467. /**
  69468. * Writes a boolean to the data storage
  69469. * @param key The key to write
  69470. * @param value The value to write
  69471. */
  69472. static WriteBoolean(key: string, value: boolean): void;
  69473. /**
  69474. * Reads a number from the data storage
  69475. * @param key The key to read
  69476. * @param defaultValue The value if the key doesn't exist
  69477. * @returns The number value
  69478. */
  69479. static ReadNumber(key: string, defaultValue: number): number;
  69480. /**
  69481. * Writes a number to the data storage
  69482. * @param key The key to write
  69483. * @param value The value to write
  69484. */
  69485. static WriteNumber(key: string, value: number): void;
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. * Options used for hit testing
  69491. */
  69492. export interface IWebXRLegacyHitTestOptions {
  69493. /**
  69494. * Only test when user interacted with the scene. Default - hit test every frame
  69495. */
  69496. testOnPointerDownOnly?: boolean;
  69497. /**
  69498. * The node to use to transform the local results to world coordinates
  69499. */
  69500. worldParentNode?: TransformNode;
  69501. }
  69502. /**
  69503. * Interface defining the babylon result of raycasting/hit-test
  69504. */
  69505. export interface IWebXRLegacyHitResult {
  69506. /**
  69507. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69508. */
  69509. transformationMatrix: Matrix;
  69510. /**
  69511. * The native hit test result
  69512. */
  69513. xrHitResult: XRHitResult | XRHitTestResult;
  69514. }
  69515. /**
  69516. * The currently-working hit-test module.
  69517. * Hit test (or Ray-casting) is used to interact with the real world.
  69518. * For further information read here - https://github.com/immersive-web/hit-test
  69519. */
  69520. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69521. /**
  69522. * options to use when constructing this feature
  69523. */
  69524. readonly options: IWebXRLegacyHitTestOptions;
  69525. private _direction;
  69526. private _mat;
  69527. private _onSelectEnabled;
  69528. private _origin;
  69529. /**
  69530. * The module's name
  69531. */
  69532. static readonly Name: string;
  69533. /**
  69534. * The (Babylon) version of this module.
  69535. * This is an integer representing the implementation version.
  69536. * This number does not correspond to the WebXR specs version
  69537. */
  69538. static readonly Version: number;
  69539. /**
  69540. * Populated with the last native XR Hit Results
  69541. */
  69542. lastNativeXRHitResults: XRHitResult[];
  69543. /**
  69544. * Triggered when new babylon (transformed) hit test results are available
  69545. */
  69546. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69547. /**
  69548. * Creates a new instance of the (legacy version) hit test feature
  69549. * @param _xrSessionManager an instance of WebXRSessionManager
  69550. * @param options options to use when constructing this feature
  69551. */
  69552. constructor(_xrSessionManager: WebXRSessionManager,
  69553. /**
  69554. * options to use when constructing this feature
  69555. */
  69556. options?: IWebXRLegacyHitTestOptions);
  69557. /**
  69558. * execute a hit test with an XR Ray
  69559. *
  69560. * @param xrSession a native xrSession that will execute this hit test
  69561. * @param xrRay the ray (position and direction) to use for ray-casting
  69562. * @param referenceSpace native XR reference space to use for the hit-test
  69563. * @param filter filter function that will filter the results
  69564. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69565. */
  69566. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69567. /**
  69568. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69569. * @param event the (select) event to use to select with
  69570. * @param referenceSpace the reference space to use for this hit test
  69571. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69572. */
  69573. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69574. /**
  69575. * attach this feature
  69576. * Will usually be called by the features manager
  69577. *
  69578. * @returns true if successful.
  69579. */
  69580. attach(): boolean;
  69581. /**
  69582. * detach this feature.
  69583. * Will usually be called by the features manager
  69584. *
  69585. * @returns true if successful.
  69586. */
  69587. detach(): boolean;
  69588. /**
  69589. * Dispose this feature and all of the resources attached
  69590. */
  69591. dispose(): void;
  69592. protected _onXRFrame(frame: XRFrame): void;
  69593. private _onHitTestResults;
  69594. private _onSelect;
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Options used in the plane detector module
  69600. */
  69601. export interface IWebXRPlaneDetectorOptions {
  69602. /**
  69603. * The node to use to transform the local results to world coordinates
  69604. */
  69605. worldParentNode?: TransformNode;
  69606. }
  69607. /**
  69608. * A babylon interface for a WebXR plane.
  69609. * A Plane is actually a polygon, built from N points in space
  69610. *
  69611. * Supported in chrome 79, not supported in canary 81 ATM
  69612. */
  69613. export interface IWebXRPlane {
  69614. /**
  69615. * a babylon-assigned ID for this polygon
  69616. */
  69617. id: number;
  69618. /**
  69619. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69620. */
  69621. polygonDefinition: Array<Vector3>;
  69622. /**
  69623. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69624. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69625. */
  69626. transformationMatrix: Matrix;
  69627. /**
  69628. * the native xr-plane object
  69629. */
  69630. xrPlane: XRPlane;
  69631. }
  69632. /**
  69633. * The plane detector is used to detect planes in the real world when in AR
  69634. * For more information see https://github.com/immersive-web/real-world-geometry/
  69635. */
  69636. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69637. private _options;
  69638. private _detectedPlanes;
  69639. private _enabled;
  69640. private _lastFrameDetected;
  69641. /**
  69642. * The module's name
  69643. */
  69644. static readonly Name: string;
  69645. /**
  69646. * The (Babylon) version of this module.
  69647. * This is an integer representing the implementation version.
  69648. * This number does not correspond to the WebXR specs version
  69649. */
  69650. static readonly Version: number;
  69651. /**
  69652. * Observers registered here will be executed when a new plane was added to the session
  69653. */
  69654. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69655. /**
  69656. * Observers registered here will be executed when a plane is no longer detected in the session
  69657. */
  69658. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69659. /**
  69660. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69661. * This can execute N times every frame
  69662. */
  69663. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69664. /**
  69665. * construct a new Plane Detector
  69666. * @param _xrSessionManager an instance of xr Session manager
  69667. * @param _options configuration to use when constructing this feature
  69668. */
  69669. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69670. /**
  69671. * Dispose this feature and all of the resources attached
  69672. */
  69673. dispose(): void;
  69674. protected _onXRFrame(frame: XRFrame): void;
  69675. private _init;
  69676. private _updatePlaneWithXRPlane;
  69677. /**
  69678. * avoiding using Array.find for global support.
  69679. * @param xrPlane the plane to find in the array
  69680. */
  69681. private findIndexInPlaneArray;
  69682. }
  69683. }
  69684. declare module BABYLON {
  69685. /**
  69686. * Configuration options of the anchor system
  69687. */
  69688. export interface IWebXRAnchorSystemOptions {
  69689. /**
  69690. * Should a new anchor be added every time a select event is triggered
  69691. */
  69692. addAnchorOnSelect?: boolean;
  69693. /**
  69694. * should the anchor system use plane detection.
  69695. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69696. */
  69697. usePlaneDetection?: boolean;
  69698. /**
  69699. * a node that will be used to convert local to world coordinates
  69700. */
  69701. worldParentNode?: TransformNode;
  69702. }
  69703. /**
  69704. * A babylon container for an XR Anchor
  69705. */
  69706. export interface IWebXRAnchor {
  69707. /**
  69708. * A babylon-assigned ID for this anchor
  69709. */
  69710. id: number;
  69711. /**
  69712. * Transformation matrix to apply to an object attached to this anchor
  69713. */
  69714. transformationMatrix: Matrix;
  69715. /**
  69716. * The native anchor object
  69717. */
  69718. xrAnchor: XRAnchor;
  69719. }
  69720. /**
  69721. * An implementation of the anchor system of WebXR.
  69722. * Note that the current documented implementation is not available in any browser. Future implementations
  69723. * will use the frame to create an anchor and not the session or a detected plane
  69724. * For further information see https://github.com/immersive-web/anchors/
  69725. */
  69726. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69727. private _options;
  69728. private _enabled;
  69729. private _hitTestModule;
  69730. private _lastFrameDetected;
  69731. private _onSelect;
  69732. private _planeDetector;
  69733. private _trackedAnchors;
  69734. /**
  69735. * The module's name
  69736. */
  69737. static readonly Name: string;
  69738. /**
  69739. * The (Babylon) version of this module.
  69740. * This is an integer representing the implementation version.
  69741. * This number does not correspond to the WebXR specs version
  69742. */
  69743. static readonly Version: number;
  69744. /**
  69745. * Observers registered here will be executed when a new anchor was added to the session
  69746. */
  69747. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69748. /**
  69749. * Observers registered here will be executed when an anchor was removed from the session
  69750. */
  69751. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69752. /**
  69753. * Observers registered here will be executed when an existing anchor updates
  69754. * This can execute N times every frame
  69755. */
  69756. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69757. /**
  69758. * constructs a new anchor system
  69759. * @param _xrSessionManager an instance of WebXRSessionManager
  69760. * @param _options configuration object for this feature
  69761. */
  69762. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69763. /**
  69764. * Add anchor at a specific XR point.
  69765. *
  69766. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69767. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69768. * @returns a promise the fulfills when the anchor was created
  69769. */
  69770. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69771. /**
  69772. * attach this feature
  69773. * Will usually be called by the features manager
  69774. *
  69775. * @returns true if successful.
  69776. */
  69777. attach(): boolean;
  69778. /**
  69779. * detach this feature.
  69780. * Will usually be called by the features manager
  69781. *
  69782. * @returns true if successful.
  69783. */
  69784. detach(): boolean;
  69785. /**
  69786. * Dispose this feature and all of the resources attached
  69787. */
  69788. dispose(): void;
  69789. /**
  69790. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69791. * @param hitTestModule the hit-test module to use.
  69792. */
  69793. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69794. /**
  69795. * set the plane detector to use in order to create anchors from frames
  69796. * @param planeDetector the plane-detector module to use
  69797. * @param enable enable plane-anchors. default is true
  69798. */
  69799. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69800. protected _onXRFrame(frame: XRFrame): void;
  69801. /**
  69802. * avoiding using Array.find for global support.
  69803. * @param xrAnchor the plane to find in the array
  69804. */
  69805. private _findIndexInAnchorArray;
  69806. private _updateAnchorWithXRFrame;
  69807. }
  69808. }
  69809. declare module BABYLON {
  69810. /**
  69811. * Options interface for the background remover plugin
  69812. */
  69813. export interface IWebXRBackgroundRemoverOptions {
  69814. /**
  69815. * Further background meshes to disable when entering AR
  69816. */
  69817. backgroundMeshes?: AbstractMesh[];
  69818. /**
  69819. * flags to configure the removal of the environment helper.
  69820. * If not set, the entire background will be removed. If set, flags should be set as well.
  69821. */
  69822. environmentHelperRemovalFlags?: {
  69823. /**
  69824. * Should the skybox be removed (default false)
  69825. */
  69826. skyBox?: boolean;
  69827. /**
  69828. * Should the ground be removed (default false)
  69829. */
  69830. ground?: boolean;
  69831. };
  69832. /**
  69833. * don't disable the environment helper
  69834. */
  69835. ignoreEnvironmentHelper?: boolean;
  69836. }
  69837. /**
  69838. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69839. */
  69840. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69841. /**
  69842. * read-only options to be used in this module
  69843. */
  69844. readonly options: IWebXRBackgroundRemoverOptions;
  69845. /**
  69846. * The module's name
  69847. */
  69848. static readonly Name: string;
  69849. /**
  69850. * The (Babylon) version of this module.
  69851. * This is an integer representing the implementation version.
  69852. * This number does not correspond to the WebXR specs version
  69853. */
  69854. static readonly Version: number;
  69855. /**
  69856. * registered observers will be triggered when the background state changes
  69857. */
  69858. onBackgroundStateChangedObservable: Observable<boolean>;
  69859. /**
  69860. * constructs a new background remover module
  69861. * @param _xrSessionManager the session manager for this module
  69862. * @param options read-only options to be used in this module
  69863. */
  69864. constructor(_xrSessionManager: WebXRSessionManager,
  69865. /**
  69866. * read-only options to be used in this module
  69867. */
  69868. options?: IWebXRBackgroundRemoverOptions);
  69869. /**
  69870. * attach this feature
  69871. * Will usually be called by the features manager
  69872. *
  69873. * @returns true if successful.
  69874. */
  69875. attach(): boolean;
  69876. /**
  69877. * detach this feature.
  69878. * Will usually be called by the features manager
  69879. *
  69880. * @returns true if successful.
  69881. */
  69882. detach(): boolean;
  69883. /**
  69884. * Dispose this feature and all of the resources attached
  69885. */
  69886. dispose(): void;
  69887. protected _onXRFrame(_xrFrame: XRFrame): void;
  69888. private _setBackgroundState;
  69889. }
  69890. }
  69891. declare module BABYLON {
  69892. /**
  69893. * Options for the controller physics feature
  69894. */
  69895. export class IWebXRControllerPhysicsOptions {
  69896. /**
  69897. * Should the headset get its own impostor
  69898. */
  69899. enableHeadsetImpostor?: boolean;
  69900. /**
  69901. * Optional parameters for the headset impostor
  69902. */
  69903. headsetImpostorParams?: {
  69904. /**
  69905. * The type of impostor to create. Default is sphere
  69906. */
  69907. impostorType: number;
  69908. /**
  69909. * the size of the impostor. Defaults to 10cm
  69910. */
  69911. impostorSize?: number | {
  69912. width: number;
  69913. height: number;
  69914. depth: number;
  69915. };
  69916. /**
  69917. * Friction definitions
  69918. */
  69919. friction?: number;
  69920. /**
  69921. * Restitution
  69922. */
  69923. restitution?: number;
  69924. };
  69925. /**
  69926. * The physics properties of the future impostors
  69927. */
  69928. physicsProperties?: {
  69929. /**
  69930. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69931. * Note that this requires a physics engine that supports mesh impostors!
  69932. */
  69933. useControllerMesh?: boolean;
  69934. /**
  69935. * The type of impostor to create. Default is sphere
  69936. */
  69937. impostorType?: number;
  69938. /**
  69939. * the size of the impostor. Defaults to 10cm
  69940. */
  69941. impostorSize?: number | {
  69942. width: number;
  69943. height: number;
  69944. depth: number;
  69945. };
  69946. /**
  69947. * Friction definitions
  69948. */
  69949. friction?: number;
  69950. /**
  69951. * Restitution
  69952. */
  69953. restitution?: number;
  69954. };
  69955. /**
  69956. * the xr input to use with this pointer selection
  69957. */
  69958. xrInput: WebXRInput;
  69959. }
  69960. /**
  69961. * Add physics impostor to your webxr controllers,
  69962. * including naive calculation of their linear and angular velocity
  69963. */
  69964. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69965. private readonly _options;
  69966. private _attachController;
  69967. private _controllers;
  69968. private _debugMode;
  69969. private _delta;
  69970. private _headsetImpostor?;
  69971. private _headsetMesh?;
  69972. private _lastTimestamp;
  69973. private _tmpQuaternion;
  69974. private _tmpVector;
  69975. /**
  69976. * The module's name
  69977. */
  69978. static readonly Name: string;
  69979. /**
  69980. * The (Babylon) version of this module.
  69981. * This is an integer representing the implementation version.
  69982. * This number does not correspond to the webxr specs version
  69983. */
  69984. static readonly Version: number;
  69985. /**
  69986. * Construct a new Controller Physics Feature
  69987. * @param _xrSessionManager the corresponding xr session manager
  69988. * @param _options options to create this feature with
  69989. */
  69990. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69991. /**
  69992. * @hidden
  69993. * enable debugging - will show console outputs and the impostor mesh
  69994. */
  69995. _enablePhysicsDebug(): void;
  69996. /**
  69997. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69998. * @param xrController the controller to add
  69999. */
  70000. addController(xrController: WebXRInputSource): void;
  70001. /**
  70002. * attach this feature
  70003. * Will usually be called by the features manager
  70004. *
  70005. * @returns true if successful.
  70006. */
  70007. attach(): boolean;
  70008. /**
  70009. * detach this feature.
  70010. * Will usually be called by the features manager
  70011. *
  70012. * @returns true if successful.
  70013. */
  70014. detach(): boolean;
  70015. /**
  70016. * Get the headset impostor, if enabled
  70017. * @returns the impostor
  70018. */
  70019. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70020. /**
  70021. * Get the physics impostor of a specific controller.
  70022. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70023. * @param controller the controller or the controller id of which to get the impostor
  70024. * @returns the impostor or null
  70025. */
  70026. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70027. /**
  70028. * Update the physics properties provided in the constructor
  70029. * @param newProperties the new properties object
  70030. */
  70031. setPhysicsProperties(newProperties: {
  70032. impostorType?: number;
  70033. impostorSize?: number | {
  70034. width: number;
  70035. height: number;
  70036. depth: number;
  70037. };
  70038. friction?: number;
  70039. restitution?: number;
  70040. }): void;
  70041. protected _onXRFrame(_xrFrame: any): void;
  70042. private _detachController;
  70043. }
  70044. }
  70045. declare module BABYLON {
  70046. /**
  70047. * Options used for hit testing (version 2)
  70048. */
  70049. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70050. /**
  70051. * Do not create a permanent hit test. Will usually be used when only
  70052. * transient inputs are needed.
  70053. */
  70054. disablePermanentHitTest?: boolean;
  70055. /**
  70056. * Enable transient (for example touch-based) hit test inspections
  70057. */
  70058. enableTransientHitTest?: boolean;
  70059. /**
  70060. * Offset ray for the permanent hit test
  70061. */
  70062. offsetRay?: Vector3;
  70063. /**
  70064. * Offset ray for the transient hit test
  70065. */
  70066. transientOffsetRay?: Vector3;
  70067. /**
  70068. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70069. */
  70070. useReferenceSpace?: boolean;
  70071. }
  70072. /**
  70073. * Interface defining the babylon result of hit-test
  70074. */
  70075. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70076. /**
  70077. * The input source that generated this hit test (if transient)
  70078. */
  70079. inputSource?: XRInputSource;
  70080. /**
  70081. * Is this a transient hit test
  70082. */
  70083. isTransient?: boolean;
  70084. /**
  70085. * Position of the hit test result
  70086. */
  70087. position: Vector3;
  70088. /**
  70089. * Rotation of the hit test result
  70090. */
  70091. rotationQuaternion: Quaternion;
  70092. }
  70093. /**
  70094. * The currently-working hit-test module.
  70095. * Hit test (or Ray-casting) is used to interact with the real world.
  70096. * For further information read here - https://github.com/immersive-web/hit-test
  70097. *
  70098. * Tested on chrome (mobile) 80.
  70099. */
  70100. export class WebXRHitTest extends WebXRAbstractFeature {
  70101. /**
  70102. * options to use when constructing this feature
  70103. */
  70104. readonly options: IWebXRHitTestOptions;
  70105. private _tmpMat;
  70106. private _tmpPos;
  70107. private _tmpQuat;
  70108. private _transientXrHitTestSource;
  70109. private _xrHitTestSource;
  70110. private initHitTestSource;
  70111. /**
  70112. * The module's name
  70113. */
  70114. static readonly Name: string;
  70115. /**
  70116. * The (Babylon) version of this module.
  70117. * This is an integer representing the implementation version.
  70118. * This number does not correspond to the WebXR specs version
  70119. */
  70120. static readonly Version: number;
  70121. /**
  70122. * When set to true, each hit test will have its own position/rotation objects
  70123. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70124. * the developers will clone them or copy them as they see fit.
  70125. */
  70126. autoCloneTransformation: boolean;
  70127. /**
  70128. * Populated with the last native XR Hit Results
  70129. */
  70130. lastNativeXRHitResults: XRHitResult[];
  70131. /**
  70132. * Triggered when new babylon (transformed) hit test results are available
  70133. */
  70134. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70135. /**
  70136. * Use this to temporarily pause hit test checks.
  70137. */
  70138. paused: boolean;
  70139. /**
  70140. * Creates a new instance of the hit test feature
  70141. * @param _xrSessionManager an instance of WebXRSessionManager
  70142. * @param options options to use when constructing this feature
  70143. */
  70144. constructor(_xrSessionManager: WebXRSessionManager,
  70145. /**
  70146. * options to use when constructing this feature
  70147. */
  70148. options?: IWebXRHitTestOptions);
  70149. /**
  70150. * attach this feature
  70151. * Will usually be called by the features manager
  70152. *
  70153. * @returns true if successful.
  70154. */
  70155. attach(): boolean;
  70156. /**
  70157. * detach this feature.
  70158. * Will usually be called by the features manager
  70159. *
  70160. * @returns true if successful.
  70161. */
  70162. detach(): boolean;
  70163. /**
  70164. * Dispose this feature and all of the resources attached
  70165. */
  70166. dispose(): void;
  70167. protected _onXRFrame(frame: XRFrame): void;
  70168. private _processWebXRHitTestResult;
  70169. }
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * The motion controller class for all microsoft mixed reality controllers
  70174. */
  70175. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70176. protected readonly _mapping: {
  70177. defaultButton: {
  70178. valueNodeName: string;
  70179. unpressedNodeName: string;
  70180. pressedNodeName: string;
  70181. };
  70182. defaultAxis: {
  70183. valueNodeName: string;
  70184. minNodeName: string;
  70185. maxNodeName: string;
  70186. };
  70187. buttons: {
  70188. "xr-standard-trigger": {
  70189. rootNodeName: string;
  70190. componentProperty: string;
  70191. states: string[];
  70192. };
  70193. "xr-standard-squeeze": {
  70194. rootNodeName: string;
  70195. componentProperty: string;
  70196. states: string[];
  70197. };
  70198. "xr-standard-touchpad": {
  70199. rootNodeName: string;
  70200. labelAnchorNodeName: string;
  70201. touchPointNodeName: string;
  70202. };
  70203. "xr-standard-thumbstick": {
  70204. rootNodeName: string;
  70205. componentProperty: string;
  70206. states: string[];
  70207. };
  70208. };
  70209. axes: {
  70210. "xr-standard-touchpad": {
  70211. "x-axis": {
  70212. rootNodeName: string;
  70213. };
  70214. "y-axis": {
  70215. rootNodeName: string;
  70216. };
  70217. };
  70218. "xr-standard-thumbstick": {
  70219. "x-axis": {
  70220. rootNodeName: string;
  70221. };
  70222. "y-axis": {
  70223. rootNodeName: string;
  70224. };
  70225. };
  70226. };
  70227. };
  70228. /**
  70229. * The base url used to load the left and right controller models
  70230. */
  70231. static MODEL_BASE_URL: string;
  70232. /**
  70233. * The name of the left controller model file
  70234. */
  70235. static MODEL_LEFT_FILENAME: string;
  70236. /**
  70237. * The name of the right controller model file
  70238. */
  70239. static MODEL_RIGHT_FILENAME: string;
  70240. profileId: string;
  70241. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70242. protected _getFilenameAndPath(): {
  70243. filename: string;
  70244. path: string;
  70245. };
  70246. protected _getModelLoadingConstraints(): boolean;
  70247. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70248. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70249. protected _updateModel(): void;
  70250. }
  70251. }
  70252. declare module BABYLON {
  70253. /**
  70254. * The motion controller class for oculus touch (quest, rift).
  70255. * This class supports legacy mapping as well the standard xr mapping
  70256. */
  70257. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70258. private _forceLegacyControllers;
  70259. private _modelRootNode;
  70260. /**
  70261. * The base url used to load the left and right controller models
  70262. */
  70263. static MODEL_BASE_URL: string;
  70264. /**
  70265. * The name of the left controller model file
  70266. */
  70267. static MODEL_LEFT_FILENAME: string;
  70268. /**
  70269. * The name of the right controller model file
  70270. */
  70271. static MODEL_RIGHT_FILENAME: string;
  70272. /**
  70273. * Base Url for the Quest controller model.
  70274. */
  70275. static QUEST_MODEL_BASE_URL: string;
  70276. profileId: string;
  70277. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70278. protected _getFilenameAndPath(): {
  70279. filename: string;
  70280. path: string;
  70281. };
  70282. protected _getModelLoadingConstraints(): boolean;
  70283. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70284. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70285. protected _updateModel(): void;
  70286. /**
  70287. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70288. * between the touch and touch 2.
  70289. */
  70290. private _isQuest;
  70291. }
  70292. }
  70293. declare module BABYLON {
  70294. /**
  70295. * The motion controller class for the standard HTC-Vive controllers
  70296. */
  70297. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70298. private _modelRootNode;
  70299. /**
  70300. * The base url used to load the left and right controller models
  70301. */
  70302. static MODEL_BASE_URL: string;
  70303. /**
  70304. * File name for the controller model.
  70305. */
  70306. static MODEL_FILENAME: string;
  70307. profileId: string;
  70308. /**
  70309. * Create a new Vive motion controller object
  70310. * @param scene the scene to use to create this controller
  70311. * @param gamepadObject the corresponding gamepad object
  70312. * @param handness the handness of the controller
  70313. */
  70314. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70315. protected _getFilenameAndPath(): {
  70316. filename: string;
  70317. path: string;
  70318. };
  70319. protected _getModelLoadingConstraints(): boolean;
  70320. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70321. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70322. protected _updateModel(): void;
  70323. }
  70324. }
  70325. declare module BABYLON {
  70326. /**
  70327. * A cursor which tracks a point on a path
  70328. */
  70329. export class PathCursor {
  70330. private path;
  70331. /**
  70332. * Stores path cursor callbacks for when an onchange event is triggered
  70333. */
  70334. private _onchange;
  70335. /**
  70336. * The value of the path cursor
  70337. */
  70338. value: number;
  70339. /**
  70340. * The animation array of the path cursor
  70341. */
  70342. animations: Animation[];
  70343. /**
  70344. * Initializes the path cursor
  70345. * @param path The path to track
  70346. */
  70347. constructor(path: Path2);
  70348. /**
  70349. * Gets the cursor point on the path
  70350. * @returns A point on the path cursor at the cursor location
  70351. */
  70352. getPoint(): Vector3;
  70353. /**
  70354. * Moves the cursor ahead by the step amount
  70355. * @param step The amount to move the cursor forward
  70356. * @returns This path cursor
  70357. */
  70358. moveAhead(step?: number): PathCursor;
  70359. /**
  70360. * Moves the cursor behind by the step amount
  70361. * @param step The amount to move the cursor back
  70362. * @returns This path cursor
  70363. */
  70364. moveBack(step?: number): PathCursor;
  70365. /**
  70366. * Moves the cursor by the step amount
  70367. * If the step amount is greater than one, an exception is thrown
  70368. * @param step The amount to move the cursor
  70369. * @returns This path cursor
  70370. */
  70371. move(step: number): PathCursor;
  70372. /**
  70373. * Ensures that the value is limited between zero and one
  70374. * @returns This path cursor
  70375. */
  70376. private ensureLimits;
  70377. /**
  70378. * Runs onchange callbacks on change (used by the animation engine)
  70379. * @returns This path cursor
  70380. */
  70381. private raiseOnChange;
  70382. /**
  70383. * Executes a function on change
  70384. * @param f A path cursor onchange callback
  70385. * @returns This path cursor
  70386. */
  70387. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70388. }
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export var blurPixelShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module BABYLON {
  70398. /** @hidden */
  70399. export var pointCloudVertexDeclaration: {
  70400. name: string;
  70401. shader: string;
  70402. };
  70403. }
  70404. // Mixins
  70405. interface Window {
  70406. mozIndexedDB: IDBFactory;
  70407. webkitIndexedDB: IDBFactory;
  70408. msIndexedDB: IDBFactory;
  70409. webkitURL: typeof URL;
  70410. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70411. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70412. WebGLRenderingContext: WebGLRenderingContext;
  70413. MSGesture: MSGesture;
  70414. CANNON: any;
  70415. AudioContext: AudioContext;
  70416. webkitAudioContext: AudioContext;
  70417. PointerEvent: any;
  70418. Math: Math;
  70419. Uint8Array: Uint8ArrayConstructor;
  70420. Float32Array: Float32ArrayConstructor;
  70421. mozURL: typeof URL;
  70422. msURL: typeof URL;
  70423. VRFrameData: any; // WebVR, from specs 1.1
  70424. DracoDecoderModule: any;
  70425. setImmediate(handler: (...args: any[]) => void): number;
  70426. }
  70427. interface HTMLCanvasElement {
  70428. requestPointerLock(): void;
  70429. msRequestPointerLock?(): void;
  70430. mozRequestPointerLock?(): void;
  70431. webkitRequestPointerLock?(): void;
  70432. /** Track wether a record is in progress */
  70433. isRecording: boolean;
  70434. /** Capture Stream method defined by some browsers */
  70435. captureStream(fps?: number): MediaStream;
  70436. }
  70437. interface CanvasRenderingContext2D {
  70438. msImageSmoothingEnabled: boolean;
  70439. }
  70440. interface MouseEvent {
  70441. mozMovementX: number;
  70442. mozMovementY: number;
  70443. webkitMovementX: number;
  70444. webkitMovementY: number;
  70445. msMovementX: number;
  70446. msMovementY: number;
  70447. }
  70448. interface Navigator {
  70449. mozGetVRDevices: (any: any) => any;
  70450. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70451. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70452. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70453. webkitGetGamepads(): Gamepad[];
  70454. msGetGamepads(): Gamepad[];
  70455. webkitGamepads(): Gamepad[];
  70456. }
  70457. interface HTMLVideoElement {
  70458. mozSrcObject: any;
  70459. }
  70460. interface Math {
  70461. fround(x: number): number;
  70462. imul(a: number, b: number): number;
  70463. }
  70464. interface WebGLRenderingContext {
  70465. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70466. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70467. vertexAttribDivisor(index: number, divisor: number): void;
  70468. createVertexArray(): any;
  70469. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70470. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70471. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70472. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70473. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70474. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70475. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70476. // Queries
  70477. createQuery(): WebGLQuery;
  70478. deleteQuery(query: WebGLQuery): void;
  70479. beginQuery(target: number, query: WebGLQuery): void;
  70480. endQuery(target: number): void;
  70481. getQueryParameter(query: WebGLQuery, pname: number): any;
  70482. getQuery(target: number, pname: number): any;
  70483. MAX_SAMPLES: number;
  70484. RGBA8: number;
  70485. READ_FRAMEBUFFER: number;
  70486. DRAW_FRAMEBUFFER: number;
  70487. UNIFORM_BUFFER: number;
  70488. HALF_FLOAT_OES: number;
  70489. RGBA16F: number;
  70490. RGBA32F: number;
  70491. R32F: number;
  70492. RG32F: number;
  70493. RGB32F: number;
  70494. R16F: number;
  70495. RG16F: number;
  70496. RGB16F: number;
  70497. RED: number;
  70498. RG: number;
  70499. R8: number;
  70500. RG8: number;
  70501. UNSIGNED_INT_24_8: number;
  70502. DEPTH24_STENCIL8: number;
  70503. MIN: number;
  70504. MAX: number;
  70505. /* Multiple Render Targets */
  70506. drawBuffers(buffers: number[]): void;
  70507. readBuffer(src: number): void;
  70508. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70509. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70510. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70511. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70512. // Occlusion Query
  70513. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70514. ANY_SAMPLES_PASSED: number;
  70515. QUERY_RESULT_AVAILABLE: number;
  70516. QUERY_RESULT: number;
  70517. }
  70518. interface WebGLProgram {
  70519. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70520. }
  70521. interface EXT_disjoint_timer_query {
  70522. QUERY_COUNTER_BITS_EXT: number;
  70523. TIME_ELAPSED_EXT: number;
  70524. TIMESTAMP_EXT: number;
  70525. GPU_DISJOINT_EXT: number;
  70526. QUERY_RESULT_EXT: number;
  70527. QUERY_RESULT_AVAILABLE_EXT: number;
  70528. queryCounterEXT(query: WebGLQuery, target: number): void;
  70529. createQueryEXT(): WebGLQuery;
  70530. beginQueryEXT(target: number, query: WebGLQuery): void;
  70531. endQueryEXT(target: number): void;
  70532. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70533. deleteQueryEXT(query: WebGLQuery): void;
  70534. }
  70535. interface WebGLUniformLocation {
  70536. _currentState: any;
  70537. }
  70538. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70539. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70540. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70541. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70542. interface WebGLRenderingContext {
  70543. readonly RASTERIZER_DISCARD: number;
  70544. readonly DEPTH_COMPONENT24: number;
  70545. readonly TEXTURE_3D: number;
  70546. readonly TEXTURE_2D_ARRAY: number;
  70547. readonly TEXTURE_COMPARE_FUNC: number;
  70548. readonly TEXTURE_COMPARE_MODE: number;
  70549. readonly COMPARE_REF_TO_TEXTURE: number;
  70550. readonly TEXTURE_WRAP_R: number;
  70551. readonly HALF_FLOAT: number;
  70552. readonly RGB8: number;
  70553. readonly RED_INTEGER: number;
  70554. readonly RG_INTEGER: number;
  70555. readonly RGB_INTEGER: number;
  70556. readonly RGBA_INTEGER: number;
  70557. readonly R8_SNORM: number;
  70558. readonly RG8_SNORM: number;
  70559. readonly RGB8_SNORM: number;
  70560. readonly RGBA8_SNORM: number;
  70561. readonly R8I: number;
  70562. readonly RG8I: number;
  70563. readonly RGB8I: number;
  70564. readonly RGBA8I: number;
  70565. readonly R8UI: number;
  70566. readonly RG8UI: number;
  70567. readonly RGB8UI: number;
  70568. readonly RGBA8UI: number;
  70569. readonly R16I: number;
  70570. readonly RG16I: number;
  70571. readonly RGB16I: number;
  70572. readonly RGBA16I: number;
  70573. readonly R16UI: number;
  70574. readonly RG16UI: number;
  70575. readonly RGB16UI: number;
  70576. readonly RGBA16UI: number;
  70577. readonly R32I: number;
  70578. readonly RG32I: number;
  70579. readonly RGB32I: number;
  70580. readonly RGBA32I: number;
  70581. readonly R32UI: number;
  70582. readonly RG32UI: number;
  70583. readonly RGB32UI: number;
  70584. readonly RGBA32UI: number;
  70585. readonly RGB10_A2UI: number;
  70586. readonly R11F_G11F_B10F: number;
  70587. readonly RGB9_E5: number;
  70588. readonly RGB10_A2: number;
  70589. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70590. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70591. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70592. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70593. readonly DEPTH_COMPONENT32F: number;
  70594. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70595. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70596. 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;
  70597. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70598. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70599. readonly TRANSFORM_FEEDBACK: number;
  70600. readonly INTERLEAVED_ATTRIBS: number;
  70601. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70602. createTransformFeedback(): WebGLTransformFeedback;
  70603. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70604. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70605. beginTransformFeedback(primitiveMode: number): void;
  70606. endTransformFeedback(): void;
  70607. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70608. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70609. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70610. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70611. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70612. }
  70613. interface ImageBitmap {
  70614. readonly width: number;
  70615. readonly height: number;
  70616. close(): void;
  70617. }
  70618. interface WebGLQuery extends WebGLObject {
  70619. }
  70620. declare var WebGLQuery: {
  70621. prototype: WebGLQuery;
  70622. new(): WebGLQuery;
  70623. };
  70624. interface WebGLSampler extends WebGLObject {
  70625. }
  70626. declare var WebGLSampler: {
  70627. prototype: WebGLSampler;
  70628. new(): WebGLSampler;
  70629. };
  70630. interface WebGLSync extends WebGLObject {
  70631. }
  70632. declare var WebGLSync: {
  70633. prototype: WebGLSync;
  70634. new(): WebGLSync;
  70635. };
  70636. interface WebGLTransformFeedback extends WebGLObject {
  70637. }
  70638. declare var WebGLTransformFeedback: {
  70639. prototype: WebGLTransformFeedback;
  70640. new(): WebGLTransformFeedback;
  70641. };
  70642. interface WebGLVertexArrayObject extends WebGLObject {
  70643. }
  70644. declare var WebGLVertexArrayObject: {
  70645. prototype: WebGLVertexArrayObject;
  70646. new(): WebGLVertexArrayObject;
  70647. };
  70648. // Type definitions for WebVR API
  70649. // Project: https://w3c.github.io/webvr/
  70650. // Definitions by: six a <https://github.com/lostfictions>
  70651. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70652. interface VRDisplay extends EventTarget {
  70653. /**
  70654. * Dictionary of capabilities describing the VRDisplay.
  70655. */
  70656. readonly capabilities: VRDisplayCapabilities;
  70657. /**
  70658. * z-depth defining the far plane of the eye view frustum
  70659. * enables mapping of values in the render target depth
  70660. * attachment to scene coordinates. Initially set to 10000.0.
  70661. */
  70662. depthFar: number;
  70663. /**
  70664. * z-depth defining the near plane of the eye view frustum
  70665. * enables mapping of values in the render target depth
  70666. * attachment to scene coordinates. Initially set to 0.01.
  70667. */
  70668. depthNear: number;
  70669. /**
  70670. * An identifier for this distinct VRDisplay. Used as an
  70671. * association point in the Gamepad API.
  70672. */
  70673. readonly displayId: number;
  70674. /**
  70675. * A display name, a user-readable name identifying it.
  70676. */
  70677. readonly displayName: string;
  70678. readonly isConnected: boolean;
  70679. readonly isPresenting: boolean;
  70680. /**
  70681. * If this VRDisplay supports room-scale experiences, the optional
  70682. * stage attribute contains details on the room-scale parameters.
  70683. */
  70684. readonly stageParameters: VRStageParameters | null;
  70685. /**
  70686. * Passing the value returned by `requestAnimationFrame` to
  70687. * `cancelAnimationFrame` will unregister the callback.
  70688. * @param handle Define the hanle of the request to cancel
  70689. */
  70690. cancelAnimationFrame(handle: number): void;
  70691. /**
  70692. * Stops presenting to the VRDisplay.
  70693. * @returns a promise to know when it stopped
  70694. */
  70695. exitPresent(): Promise<void>;
  70696. /**
  70697. * Return the current VREyeParameters for the given eye.
  70698. * @param whichEye Define the eye we want the parameter for
  70699. * @returns the eye parameters
  70700. */
  70701. getEyeParameters(whichEye: string): VREyeParameters;
  70702. /**
  70703. * Populates the passed VRFrameData with the information required to render
  70704. * the current frame.
  70705. * @param frameData Define the data structure to populate
  70706. * @returns true if ok otherwise false
  70707. */
  70708. getFrameData(frameData: VRFrameData): boolean;
  70709. /**
  70710. * Get the layers currently being presented.
  70711. * @returns the list of VR layers
  70712. */
  70713. getLayers(): VRLayer[];
  70714. /**
  70715. * Return a VRPose containing the future predicted pose of the VRDisplay
  70716. * when the current frame will be presented. The value returned will not
  70717. * change until JavaScript has returned control to the browser.
  70718. *
  70719. * The VRPose will contain the position, orientation, velocity,
  70720. * and acceleration of each of these properties.
  70721. * @returns the pose object
  70722. */
  70723. getPose(): VRPose;
  70724. /**
  70725. * Return the current instantaneous pose of the VRDisplay, with no
  70726. * prediction applied.
  70727. * @returns the current instantaneous pose
  70728. */
  70729. getImmediatePose(): VRPose;
  70730. /**
  70731. * The callback passed to `requestAnimationFrame` will be called
  70732. * any time a new frame should be rendered. When the VRDisplay is
  70733. * presenting the callback will be called at the native refresh
  70734. * rate of the HMD. When not presenting this function acts
  70735. * identically to how window.requestAnimationFrame acts. Content should
  70736. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70737. * asynchronously from other displays and at differing refresh rates.
  70738. * @param callback Define the eaction to run next frame
  70739. * @returns the request handle it
  70740. */
  70741. requestAnimationFrame(callback: FrameRequestCallback): number;
  70742. /**
  70743. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70744. * Repeat calls while already presenting will update the VRLayers being displayed.
  70745. * @param layers Define the list of layer to present
  70746. * @returns a promise to know when the request has been fulfilled
  70747. */
  70748. requestPresent(layers: VRLayer[]): Promise<void>;
  70749. /**
  70750. * Reset the pose for this display, treating its current position and
  70751. * orientation as the "origin/zero" values. VRPose.position,
  70752. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70753. * updated when calling resetPose(). This should be called in only
  70754. * sitting-space experiences.
  70755. */
  70756. resetPose(): void;
  70757. /**
  70758. * The VRLayer provided to the VRDisplay will be captured and presented
  70759. * in the HMD. Calling this function has the same effect on the source
  70760. * canvas as any other operation that uses its source image, and canvases
  70761. * created without preserveDrawingBuffer set to true will be cleared.
  70762. * @param pose Define the pose to submit
  70763. */
  70764. submitFrame(pose?: VRPose): void;
  70765. }
  70766. declare var VRDisplay: {
  70767. prototype: VRDisplay;
  70768. new(): VRDisplay;
  70769. };
  70770. interface VRLayer {
  70771. leftBounds?: number[] | Float32Array | null;
  70772. rightBounds?: number[] | Float32Array | null;
  70773. source?: HTMLCanvasElement | null;
  70774. }
  70775. interface VRDisplayCapabilities {
  70776. readonly canPresent: boolean;
  70777. readonly hasExternalDisplay: boolean;
  70778. readonly hasOrientation: boolean;
  70779. readonly hasPosition: boolean;
  70780. readonly maxLayers: number;
  70781. }
  70782. interface VREyeParameters {
  70783. /** @deprecated */
  70784. readonly fieldOfView: VRFieldOfView;
  70785. readonly offset: Float32Array;
  70786. readonly renderHeight: number;
  70787. readonly renderWidth: number;
  70788. }
  70789. interface VRFieldOfView {
  70790. readonly downDegrees: number;
  70791. readonly leftDegrees: number;
  70792. readonly rightDegrees: number;
  70793. readonly upDegrees: number;
  70794. }
  70795. interface VRFrameData {
  70796. readonly leftProjectionMatrix: Float32Array;
  70797. readonly leftViewMatrix: Float32Array;
  70798. readonly pose: VRPose;
  70799. readonly rightProjectionMatrix: Float32Array;
  70800. readonly rightViewMatrix: Float32Array;
  70801. readonly timestamp: number;
  70802. }
  70803. interface VRPose {
  70804. readonly angularAcceleration: Float32Array | null;
  70805. readonly angularVelocity: Float32Array | null;
  70806. readonly linearAcceleration: Float32Array | null;
  70807. readonly linearVelocity: Float32Array | null;
  70808. readonly orientation: Float32Array | null;
  70809. readonly position: Float32Array | null;
  70810. readonly timestamp: number;
  70811. }
  70812. interface VRStageParameters {
  70813. sittingToStandingTransform?: Float32Array;
  70814. sizeX?: number;
  70815. sizeY?: number;
  70816. }
  70817. interface Navigator {
  70818. getVRDisplays(): Promise<VRDisplay[]>;
  70819. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70820. }
  70821. interface Window {
  70822. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70823. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70824. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70825. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70826. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70827. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70828. }
  70829. interface Gamepad {
  70830. readonly displayId: number;
  70831. }
  70832. type XRSessionMode =
  70833. | "inline"
  70834. | "immersive-vr"
  70835. | "immersive-ar";
  70836. type XRReferenceSpaceType =
  70837. | "viewer"
  70838. | "local"
  70839. | "local-floor"
  70840. | "bounded-floor"
  70841. | "unbounded";
  70842. type XREnvironmentBlendMode =
  70843. | "opaque"
  70844. | "additive"
  70845. | "alpha-blend";
  70846. type XRVisibilityState =
  70847. | "visible"
  70848. | "visible-blurred"
  70849. | "hidden";
  70850. type XRHandedness =
  70851. | "none"
  70852. | "left"
  70853. | "right";
  70854. type XRTargetRayMode =
  70855. | "gaze"
  70856. | "tracked-pointer"
  70857. | "screen";
  70858. type XREye =
  70859. | "none"
  70860. | "left"
  70861. | "right";
  70862. interface XRSpace extends EventTarget {
  70863. }
  70864. interface XRRenderState {
  70865. depthNear?: number;
  70866. depthFar?: number;
  70867. inlineVerticalFieldOfView?: number;
  70868. baseLayer?: XRWebGLLayer;
  70869. }
  70870. interface XRInputSource {
  70871. handedness: XRHandedness;
  70872. targetRayMode: XRTargetRayMode;
  70873. targetRaySpace: XRSpace;
  70874. gripSpace: XRSpace | undefined;
  70875. gamepad: Gamepad | undefined;
  70876. profiles: Array<string>;
  70877. }
  70878. interface XRSessionInit {
  70879. optionalFeatures?: XRReferenceSpaceType[];
  70880. requiredFeatures?: XRReferenceSpaceType[];
  70881. }
  70882. interface XRSession extends XRAnchorCreator {
  70883. addEventListener: Function;
  70884. removeEventListener: Function;
  70885. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70886. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70887. requestAnimationFrame: Function;
  70888. end(): Promise<void>;
  70889. renderState: XRRenderState;
  70890. inputSources: Array<XRInputSource>;
  70891. // hit test
  70892. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70893. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70894. // legacy AR hit test
  70895. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70896. // legacy plane detection
  70897. updateWorldTrackingState(options: {
  70898. planeDetectionState?: { enabled: boolean; }
  70899. }): void;
  70900. }
  70901. interface XRReferenceSpace extends XRSpace {
  70902. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70903. onreset: any;
  70904. }
  70905. type XRPlaneSet = Set<XRPlane>;
  70906. type XRAnchorSet = Set<XRAnchor>;
  70907. interface XRFrame {
  70908. session: XRSession;
  70909. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70910. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70911. // AR
  70912. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70913. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70914. // Anchors
  70915. trackedAnchors?: XRAnchorSet;
  70916. // Planes
  70917. worldInformation: {
  70918. detectedPlanes?: XRPlaneSet;
  70919. };
  70920. }
  70921. interface XRViewerPose extends XRPose {
  70922. views: Array<XRView>;
  70923. }
  70924. interface XRPose {
  70925. transform: XRRigidTransform;
  70926. emulatedPosition: boolean;
  70927. }
  70928. interface XRWebGLLayerOptions {
  70929. antialias?: boolean;
  70930. depth?: boolean;
  70931. stencil?: boolean;
  70932. alpha?: boolean;
  70933. multiview?: boolean;
  70934. framebufferScaleFactor?: number;
  70935. }
  70936. declare var XRWebGLLayer: {
  70937. prototype: XRWebGLLayer;
  70938. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70939. };
  70940. interface XRWebGLLayer {
  70941. framebuffer: WebGLFramebuffer;
  70942. framebufferWidth: number;
  70943. framebufferHeight: number;
  70944. getViewport: Function;
  70945. }
  70946. declare class XRRigidTransform {
  70947. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70948. position: DOMPointReadOnly;
  70949. orientation: DOMPointReadOnly;
  70950. matrix: Float32Array;
  70951. inverse: XRRigidTransform;
  70952. }
  70953. interface XRView {
  70954. eye: XREye;
  70955. projectionMatrix: Float32Array;
  70956. transform: XRRigidTransform;
  70957. }
  70958. interface XRInputSourceChangeEvent {
  70959. session: XRSession;
  70960. removed: Array<XRInputSource>;
  70961. added: Array<XRInputSource>;
  70962. }
  70963. interface XRInputSourceEvent extends Event {
  70964. readonly frame: XRFrame;
  70965. readonly inputSource: XRInputSource;
  70966. }
  70967. // Experimental(er) features
  70968. declare class XRRay {
  70969. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70970. origin: DOMPointReadOnly;
  70971. direction: DOMPointReadOnly;
  70972. matrix: Float32Array;
  70973. }
  70974. declare enum XRHitTestTrackableType {
  70975. "point",
  70976. "plane"
  70977. }
  70978. interface XRHitResult {
  70979. hitMatrix: Float32Array;
  70980. }
  70981. interface XRTransientInputHitTestResult {
  70982. readonly inputSource: XRInputSource;
  70983. readonly results: Array<XRHitTestResult>;
  70984. }
  70985. interface XRHitTestResult {
  70986. getPose(baseSpace: XRSpace): XRPose | undefined;
  70987. }
  70988. interface XRHitTestSource {
  70989. cancel(): void;
  70990. }
  70991. interface XRTransientInputHitTestSource {
  70992. cancel(): void;
  70993. }
  70994. interface XRHitTestOptionsInit {
  70995. space: XRSpace;
  70996. entityTypes?: Array<XRHitTestTrackableType>;
  70997. offsetRay?: XRRay;
  70998. }
  70999. interface XRTransientInputHitTestOptionsInit {
  71000. profile: string;
  71001. entityTypes?: Array<XRHitTestTrackableType>;
  71002. offsetRay?: XRRay;
  71003. }
  71004. interface XRAnchor {
  71005. // remove?
  71006. id?: string;
  71007. anchorSpace: XRSpace;
  71008. lastChangedTime: number;
  71009. detach(): void;
  71010. }
  71011. interface XRPlane extends XRAnchorCreator {
  71012. orientation: "Horizontal" | "Vertical";
  71013. planeSpace: XRSpace;
  71014. polygon: Array<DOMPointReadOnly>;
  71015. lastChangedTime: number;
  71016. }
  71017. interface XRAnchorCreator {
  71018. // AR Anchors
  71019. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71020. }
  71021. /**
  71022. * @ignore
  71023. */
  71024. declare module BABYLON.GLTF2.Exporter {
  71025. }
  71026. /**
  71027. * @ignore
  71028. */
  71029. declare module BABYLON.GLTF1 {
  71030. }
  71031. declare module BABYLON.GUI {
  71032. /**
  71033. * Class used to specific a value and its associated unit
  71034. */
  71035. export class ValueAndUnit {
  71036. /** defines the unit to store */
  71037. unit: number;
  71038. /** defines a boolean indicating if the value can be negative */
  71039. negativeValueAllowed: boolean;
  71040. private _value;
  71041. private _originalUnit;
  71042. /**
  71043. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71044. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71045. */
  71046. ignoreAdaptiveScaling: boolean;
  71047. /**
  71048. * Creates a new ValueAndUnit
  71049. * @param value defines the value to store
  71050. * @param unit defines the unit to store
  71051. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71052. */
  71053. constructor(value: number,
  71054. /** defines the unit to store */
  71055. unit?: number,
  71056. /** defines a boolean indicating if the value can be negative */
  71057. negativeValueAllowed?: boolean);
  71058. /** Gets a boolean indicating if the value is a percentage */
  71059. get isPercentage(): boolean;
  71060. /** Gets a boolean indicating if the value is store as pixel */
  71061. get isPixel(): boolean;
  71062. /** Gets direct internal value */
  71063. get internalValue(): number;
  71064. /**
  71065. * Gets value as pixel
  71066. * @param host defines the root host
  71067. * @param refValue defines the reference value for percentages
  71068. * @returns the value as pixel
  71069. */
  71070. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71071. /**
  71072. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71073. * @param value defines the value to store
  71074. * @param unit defines the unit to store
  71075. * @returns the current ValueAndUnit
  71076. */
  71077. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71078. /**
  71079. * Gets the value accordingly to its unit
  71080. * @param host defines the root host
  71081. * @returns the value
  71082. */
  71083. getValue(host: AdvancedDynamicTexture): number;
  71084. /**
  71085. * Gets a string representation of the value
  71086. * @param host defines the root host
  71087. * @param decimals defines an optional number of decimals to display
  71088. * @returns a string
  71089. */
  71090. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71091. /**
  71092. * Store a value parsed from a string
  71093. * @param source defines the source string
  71094. * @returns true if the value was successfully parsed
  71095. */
  71096. fromString(source: string | number): boolean;
  71097. private static _Regex;
  71098. private static _UNITMODE_PERCENTAGE;
  71099. private static _UNITMODE_PIXEL;
  71100. /** UNITMODE_PERCENTAGE */
  71101. static get UNITMODE_PERCENTAGE(): number;
  71102. /** UNITMODE_PIXEL */
  71103. static get UNITMODE_PIXEL(): number;
  71104. }
  71105. }
  71106. declare module BABYLON.GUI {
  71107. /**
  71108. * Define a style used by control to automatically setup properties based on a template.
  71109. * Only support font related properties so far
  71110. */
  71111. export class Style implements BABYLON.IDisposable {
  71112. private _fontFamily;
  71113. private _fontStyle;
  71114. private _fontWeight;
  71115. /** @hidden */
  71116. _host: AdvancedDynamicTexture;
  71117. /** @hidden */
  71118. _fontSize: ValueAndUnit;
  71119. /**
  71120. * BABYLON.Observable raised when the style values are changed
  71121. */
  71122. onChangedObservable: BABYLON.Observable<Style>;
  71123. /**
  71124. * Creates a new style object
  71125. * @param host defines the AdvancedDynamicTexture which hosts this style
  71126. */
  71127. constructor(host: AdvancedDynamicTexture);
  71128. /**
  71129. * Gets or sets the font size
  71130. */
  71131. get fontSize(): string | number;
  71132. set fontSize(value: string | number);
  71133. /**
  71134. * Gets or sets the font family
  71135. */
  71136. get fontFamily(): string;
  71137. set fontFamily(value: string);
  71138. /**
  71139. * Gets or sets the font style
  71140. */
  71141. get fontStyle(): string;
  71142. set fontStyle(value: string);
  71143. /** Gets or sets font weight */
  71144. get fontWeight(): string;
  71145. set fontWeight(value: string);
  71146. /** Dispose all associated resources */
  71147. dispose(): void;
  71148. }
  71149. }
  71150. declare module BABYLON.GUI {
  71151. /**
  71152. * Class used to transport BABYLON.Vector2 information for pointer events
  71153. */
  71154. export class Vector2WithInfo extends BABYLON.Vector2 {
  71155. /** defines the current mouse button index */
  71156. buttonIndex: number;
  71157. /**
  71158. * Creates a new Vector2WithInfo
  71159. * @param source defines the vector2 data to transport
  71160. * @param buttonIndex defines the current mouse button index
  71161. */
  71162. constructor(source: BABYLON.Vector2,
  71163. /** defines the current mouse button index */
  71164. buttonIndex?: number);
  71165. }
  71166. /** Class used to provide 2D matrix features */
  71167. export class Matrix2D {
  71168. /** Gets the internal array of 6 floats used to store matrix data */
  71169. m: Float32Array;
  71170. /**
  71171. * Creates a new matrix
  71172. * @param m00 defines value for (0, 0)
  71173. * @param m01 defines value for (0, 1)
  71174. * @param m10 defines value for (1, 0)
  71175. * @param m11 defines value for (1, 1)
  71176. * @param m20 defines value for (2, 0)
  71177. * @param m21 defines value for (2, 1)
  71178. */
  71179. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71180. /**
  71181. * Fills the matrix from direct values
  71182. * @param m00 defines value for (0, 0)
  71183. * @param m01 defines value for (0, 1)
  71184. * @param m10 defines value for (1, 0)
  71185. * @param m11 defines value for (1, 1)
  71186. * @param m20 defines value for (2, 0)
  71187. * @param m21 defines value for (2, 1)
  71188. * @returns the current modified matrix
  71189. */
  71190. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71191. /**
  71192. * Gets matrix determinant
  71193. * @returns the determinant
  71194. */
  71195. determinant(): number;
  71196. /**
  71197. * Inverses the matrix and stores it in a target matrix
  71198. * @param result defines the target matrix
  71199. * @returns the current matrix
  71200. */
  71201. invertToRef(result: Matrix2D): Matrix2D;
  71202. /**
  71203. * Multiplies the current matrix with another one
  71204. * @param other defines the second operand
  71205. * @param result defines the target matrix
  71206. * @returns the current matrix
  71207. */
  71208. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71209. /**
  71210. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71211. * @param x defines the x coordinate to transform
  71212. * @param y defines the x coordinate to transform
  71213. * @param result defines the target vector2
  71214. * @returns the current matrix
  71215. */
  71216. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71217. /**
  71218. * Creates an identity matrix
  71219. * @returns a new matrix
  71220. */
  71221. static Identity(): Matrix2D;
  71222. /**
  71223. * Creates a translation matrix and stores it in a target matrix
  71224. * @param x defines the x coordinate of the translation
  71225. * @param y defines the y coordinate of the translation
  71226. * @param result defines the target matrix
  71227. */
  71228. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71229. /**
  71230. * Creates a scaling matrix and stores it in a target matrix
  71231. * @param x defines the x coordinate of the scaling
  71232. * @param y defines the y coordinate of the scaling
  71233. * @param result defines the target matrix
  71234. */
  71235. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71236. /**
  71237. * Creates a rotation matrix and stores it in a target matrix
  71238. * @param angle defines the rotation angle
  71239. * @param result defines the target matrix
  71240. */
  71241. static RotationToRef(angle: number, result: Matrix2D): void;
  71242. private static _TempPreTranslationMatrix;
  71243. private static _TempPostTranslationMatrix;
  71244. private static _TempRotationMatrix;
  71245. private static _TempScalingMatrix;
  71246. private static _TempCompose0;
  71247. private static _TempCompose1;
  71248. private static _TempCompose2;
  71249. /**
  71250. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71251. * @param tx defines the x coordinate of the translation
  71252. * @param ty defines the y coordinate of the translation
  71253. * @param angle defines the rotation angle
  71254. * @param scaleX defines the x coordinate of the scaling
  71255. * @param scaleY defines the y coordinate of the scaling
  71256. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71257. * @param result defines the target matrix
  71258. */
  71259. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71260. }
  71261. }
  71262. declare module BABYLON.GUI {
  71263. /**
  71264. * Class used to store 2D control sizes
  71265. */
  71266. export class Measure {
  71267. /** defines left coordinate */
  71268. left: number;
  71269. /** defines top coordinate */
  71270. top: number;
  71271. /** defines width dimension */
  71272. width: number;
  71273. /** defines height dimension */
  71274. height: number;
  71275. /**
  71276. * Creates a new measure
  71277. * @param left defines left coordinate
  71278. * @param top defines top coordinate
  71279. * @param width defines width dimension
  71280. * @param height defines height dimension
  71281. */
  71282. constructor(
  71283. /** defines left coordinate */
  71284. left: number,
  71285. /** defines top coordinate */
  71286. top: number,
  71287. /** defines width dimension */
  71288. width: number,
  71289. /** defines height dimension */
  71290. height: number);
  71291. /**
  71292. * Copy from another measure
  71293. * @param other defines the other measure to copy from
  71294. */
  71295. copyFrom(other: Measure): void;
  71296. /**
  71297. * Copy from a group of 4 floats
  71298. * @param left defines left coordinate
  71299. * @param top defines top coordinate
  71300. * @param width defines width dimension
  71301. * @param height defines height dimension
  71302. */
  71303. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71304. /**
  71305. * Computes the axis aligned bounding box measure for two given measures
  71306. * @param a Input measure
  71307. * @param b Input measure
  71308. * @param result the resulting bounding measure
  71309. */
  71310. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71311. /**
  71312. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71313. * @param transform the matrix to transform the measure before computing the AABB
  71314. * @param result the resulting AABB
  71315. */
  71316. transformToRef(transform: Matrix2D, result: Measure): void;
  71317. /**
  71318. * Check equality between this measure and another one
  71319. * @param other defines the other measures
  71320. * @returns true if both measures are equals
  71321. */
  71322. isEqualsTo(other: Measure): boolean;
  71323. /**
  71324. * Creates an empty measure
  71325. * @returns a new measure
  71326. */
  71327. static Empty(): Measure;
  71328. }
  71329. }
  71330. declare module BABYLON.GUI {
  71331. /**
  71332. * Interface used to define a control that can receive focus
  71333. */
  71334. export interface IFocusableControl {
  71335. /**
  71336. * Function called when the control receives the focus
  71337. */
  71338. onFocus(): void;
  71339. /**
  71340. * Function called when the control loses the focus
  71341. */
  71342. onBlur(): void;
  71343. /**
  71344. * Function called to let the control handle keyboard events
  71345. * @param evt defines the current keyboard event
  71346. */
  71347. processKeyboard(evt: KeyboardEvent): void;
  71348. /**
  71349. * Function called to get the list of controls that should not steal the focus from this control
  71350. * @returns an array of controls
  71351. */
  71352. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71353. }
  71354. /**
  71355. * Class used to create texture to support 2D GUI elements
  71356. * @see http://doc.babylonjs.com/how_to/gui
  71357. */
  71358. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71359. private _isDirty;
  71360. private _renderObserver;
  71361. private _resizeObserver;
  71362. private _preKeyboardObserver;
  71363. private _pointerMoveObserver;
  71364. private _pointerObserver;
  71365. private _canvasPointerOutObserver;
  71366. private _background;
  71367. /** @hidden */
  71368. _rootContainer: Container;
  71369. /** @hidden */
  71370. _lastPickedControl: Control;
  71371. /** @hidden */
  71372. _lastControlOver: {
  71373. [pointerId: number]: Control;
  71374. };
  71375. /** @hidden */
  71376. _lastControlDown: {
  71377. [pointerId: number]: Control;
  71378. };
  71379. /** @hidden */
  71380. _capturingControl: {
  71381. [pointerId: number]: Control;
  71382. };
  71383. /** @hidden */
  71384. _shouldBlockPointer: boolean;
  71385. /** @hidden */
  71386. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71387. /** @hidden */
  71388. _linkedControls: Control[];
  71389. private _isFullscreen;
  71390. private _fullscreenViewport;
  71391. private _idealWidth;
  71392. private _idealHeight;
  71393. private _useSmallestIdeal;
  71394. private _renderAtIdealSize;
  71395. private _focusedControl;
  71396. private _blockNextFocusCheck;
  71397. private _renderScale;
  71398. private _rootElement;
  71399. private _cursorChanged;
  71400. private _defaultMousePointerId;
  71401. /** @hidden */
  71402. _numLayoutCalls: number;
  71403. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71404. get numLayoutCalls(): number;
  71405. /** @hidden */
  71406. _numRenderCalls: number;
  71407. /** Gets the number of render calls made the last time the ADT has been rendered */
  71408. get numRenderCalls(): number;
  71409. /**
  71410. * Define type to string to ensure compatibility across browsers
  71411. * Safari doesn't support DataTransfer constructor
  71412. */
  71413. private _clipboardData;
  71414. /**
  71415. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71416. */
  71417. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71418. /**
  71419. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71420. */
  71421. onControlPickedObservable: BABYLON.Observable<Control>;
  71422. /**
  71423. * BABYLON.Observable event triggered before layout is evaluated
  71424. */
  71425. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71426. /**
  71427. * BABYLON.Observable event triggered after the layout was evaluated
  71428. */
  71429. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71430. /**
  71431. * BABYLON.Observable event triggered before the texture is rendered
  71432. */
  71433. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71434. /**
  71435. * BABYLON.Observable event triggered after the texture was rendered
  71436. */
  71437. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71438. /**
  71439. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71440. */
  71441. premulAlpha: boolean;
  71442. /**
  71443. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71444. * Useful when you want more antialiasing
  71445. */
  71446. get renderScale(): number;
  71447. set renderScale(value: number);
  71448. /** Gets or sets the background color */
  71449. get background(): string;
  71450. set background(value: string);
  71451. /**
  71452. * Gets or sets the ideal width used to design controls.
  71453. * The GUI will then rescale everything accordingly
  71454. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71455. */
  71456. get idealWidth(): number;
  71457. set idealWidth(value: number);
  71458. /**
  71459. * Gets or sets the ideal height used to design controls.
  71460. * The GUI will then rescale everything accordingly
  71461. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71462. */
  71463. get idealHeight(): number;
  71464. set idealHeight(value: number);
  71465. /**
  71466. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71467. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71468. */
  71469. get useSmallestIdeal(): boolean;
  71470. set useSmallestIdeal(value: boolean);
  71471. /**
  71472. * Gets or sets a boolean indicating if adaptive scaling must be used
  71473. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71474. */
  71475. get renderAtIdealSize(): boolean;
  71476. set renderAtIdealSize(value: boolean);
  71477. /**
  71478. * Gets the ratio used when in "ideal mode"
  71479. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71480. * */
  71481. get idealRatio(): number;
  71482. /**
  71483. * Gets the underlying layer used to render the texture when in fullscreen mode
  71484. */
  71485. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71486. /**
  71487. * Gets the root container control
  71488. */
  71489. get rootContainer(): Container;
  71490. /**
  71491. * Returns an array containing the root container.
  71492. * This is mostly used to let the Inspector introspects the ADT
  71493. * @returns an array containing the rootContainer
  71494. */
  71495. getChildren(): Array<Container>;
  71496. /**
  71497. * Will return all controls that are inside this texture
  71498. * @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
  71499. * @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
  71500. * @return all child controls
  71501. */
  71502. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71503. /**
  71504. * Gets or sets the current focused control
  71505. */
  71506. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71507. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71508. /**
  71509. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71510. */
  71511. get isForeground(): boolean;
  71512. set isForeground(value: boolean);
  71513. /**
  71514. * Gets or set information about clipboardData
  71515. */
  71516. get clipboardData(): string;
  71517. set clipboardData(value: string);
  71518. /**
  71519. * Creates a new AdvancedDynamicTexture
  71520. * @param name defines the name of the texture
  71521. * @param width defines the width of the texture
  71522. * @param height defines the height of the texture
  71523. * @param scene defines the hosting scene
  71524. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71525. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71526. */
  71527. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71528. /**
  71529. * Get the current class name of the texture useful for serialization or dynamic coding.
  71530. * @returns "AdvancedDynamicTexture"
  71531. */
  71532. getClassName(): string;
  71533. /**
  71534. * Function used to execute a function on all controls
  71535. * @param func defines the function to execute
  71536. * @param container defines the container where controls belong. If null the root container will be used
  71537. */
  71538. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71539. private _useInvalidateRectOptimization;
  71540. /**
  71541. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71542. */
  71543. get useInvalidateRectOptimization(): boolean;
  71544. set useInvalidateRectOptimization(value: boolean);
  71545. private _invalidatedRectangle;
  71546. /**
  71547. * Invalidates a rectangle area on the gui texture
  71548. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71549. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71550. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71551. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71552. */
  71553. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71554. /**
  71555. * Marks the texture as dirty forcing a complete update
  71556. */
  71557. markAsDirty(): void;
  71558. /**
  71559. * Helper function used to create a new style
  71560. * @returns a new style
  71561. * @see http://doc.babylonjs.com/how_to/gui#styles
  71562. */
  71563. createStyle(): Style;
  71564. /**
  71565. * Adds a new control to the root container
  71566. * @param control defines the control to add
  71567. * @returns the current texture
  71568. */
  71569. addControl(control: Control): AdvancedDynamicTexture;
  71570. /**
  71571. * Removes a control from the root container
  71572. * @param control defines the control to remove
  71573. * @returns the current texture
  71574. */
  71575. removeControl(control: Control): AdvancedDynamicTexture;
  71576. /**
  71577. * Release all resources
  71578. */
  71579. dispose(): void;
  71580. private _onResize;
  71581. /** @hidden */
  71582. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71583. /**
  71584. * Get screen coordinates for a vector3
  71585. * @param position defines the position to project
  71586. * @param worldMatrix defines the world matrix to use
  71587. * @returns the projected position
  71588. */
  71589. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71590. private _checkUpdate;
  71591. private _clearMeasure;
  71592. private _render;
  71593. /** @hidden */
  71594. _changeCursor(cursor: string): void;
  71595. /** @hidden */
  71596. _registerLastControlDown(control: Control, pointerId: number): void;
  71597. private _doPicking;
  71598. /** @hidden */
  71599. _cleanControlAfterRemovalFromList(list: {
  71600. [pointerId: number]: Control;
  71601. }, control: Control): void;
  71602. /** @hidden */
  71603. _cleanControlAfterRemoval(control: Control): void;
  71604. /** Attach to all scene events required to support pointer events */
  71605. attach(): void;
  71606. /** @hidden */
  71607. private onClipboardCopy;
  71608. /** @hidden */
  71609. private onClipboardCut;
  71610. /** @hidden */
  71611. private onClipboardPaste;
  71612. /**
  71613. * Register the clipboard Events onto the canvas
  71614. */
  71615. registerClipboardEvents(): void;
  71616. /**
  71617. * Unregister the clipboard Events from the canvas
  71618. */
  71619. unRegisterClipboardEvents(): void;
  71620. /**
  71621. * Connect the texture to a hosting mesh to enable interactions
  71622. * @param mesh defines the mesh to attach to
  71623. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71624. */
  71625. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71626. /**
  71627. * Move the focus to a specific control
  71628. * @param control defines the control which will receive the focus
  71629. */
  71630. moveFocusToControl(control: IFocusableControl): void;
  71631. private _manageFocus;
  71632. private _attachToOnPointerOut;
  71633. /**
  71634. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71635. * @param mesh defines the mesh which will receive the texture
  71636. * @param width defines the texture width (1024 by default)
  71637. * @param height defines the texture height (1024 by default)
  71638. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71639. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71640. * @returns a new AdvancedDynamicTexture
  71641. */
  71642. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71643. /**
  71644. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71645. * In this mode the texture will rely on a layer for its rendering.
  71646. * This allows it to be treated like any other layer.
  71647. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71648. * LayerMask is set through advancedTexture.layer.layerMask
  71649. * @param name defines name for the texture
  71650. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71651. * @param scene defines the hsoting scene
  71652. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71653. * @returns a new AdvancedDynamicTexture
  71654. */
  71655. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71656. }
  71657. }
  71658. declare module BABYLON.GUI {
  71659. /**
  71660. * Root class used for all 2D controls
  71661. * @see http://doc.babylonjs.com/how_to/gui#controls
  71662. */
  71663. export class Control {
  71664. /** defines the name of the control */
  71665. name?: string | undefined;
  71666. /**
  71667. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71668. */
  71669. static AllowAlphaInheritance: boolean;
  71670. private _alpha;
  71671. private _alphaSet;
  71672. private _zIndex;
  71673. /** @hidden */
  71674. _host: AdvancedDynamicTexture;
  71675. /** Gets or sets the control parent */
  71676. parent: BABYLON.Nullable<Container>;
  71677. /** @hidden */
  71678. _currentMeasure: Measure;
  71679. private _fontFamily;
  71680. private _fontStyle;
  71681. private _fontWeight;
  71682. private _fontSize;
  71683. private _font;
  71684. /** @hidden */
  71685. _width: ValueAndUnit;
  71686. /** @hidden */
  71687. _height: ValueAndUnit;
  71688. /** @hidden */
  71689. protected _fontOffset: {
  71690. ascent: number;
  71691. height: number;
  71692. descent: number;
  71693. };
  71694. private _color;
  71695. private _style;
  71696. private _styleObserver;
  71697. /** @hidden */
  71698. protected _horizontalAlignment: number;
  71699. /** @hidden */
  71700. protected _verticalAlignment: number;
  71701. /** @hidden */
  71702. protected _isDirty: boolean;
  71703. /** @hidden */
  71704. protected _wasDirty: boolean;
  71705. /** @hidden */
  71706. _tempParentMeasure: Measure;
  71707. /** @hidden */
  71708. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71709. /** @hidden */
  71710. protected _cachedParentMeasure: Measure;
  71711. private _paddingLeft;
  71712. private _paddingRight;
  71713. private _paddingTop;
  71714. private _paddingBottom;
  71715. /** @hidden */
  71716. _left: ValueAndUnit;
  71717. /** @hidden */
  71718. _top: ValueAndUnit;
  71719. private _scaleX;
  71720. private _scaleY;
  71721. private _rotation;
  71722. private _transformCenterX;
  71723. private _transformCenterY;
  71724. /** @hidden */
  71725. _transformMatrix: Matrix2D;
  71726. /** @hidden */
  71727. protected _invertTransformMatrix: Matrix2D;
  71728. /** @hidden */
  71729. protected _transformedPosition: BABYLON.Vector2;
  71730. private _isMatrixDirty;
  71731. private _cachedOffsetX;
  71732. private _cachedOffsetY;
  71733. private _isVisible;
  71734. private _isHighlighted;
  71735. /** @hidden */
  71736. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71737. private _fontSet;
  71738. private _dummyVector2;
  71739. private _downCount;
  71740. private _enterCount;
  71741. private _doNotRender;
  71742. private _downPointerIds;
  71743. protected _isEnabled: boolean;
  71744. protected _disabledColor: string;
  71745. protected _disabledColorItem: string;
  71746. /** @hidden */
  71747. protected _rebuildLayout: boolean;
  71748. /** @hidden */
  71749. _customData: any;
  71750. /** @hidden */
  71751. _isClipped: boolean;
  71752. /** @hidden */
  71753. _automaticSize: boolean;
  71754. /** @hidden */
  71755. _tag: any;
  71756. /**
  71757. * 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
  71758. */
  71759. uniqueId: number;
  71760. /**
  71761. * Gets or sets an object used to store user defined information for the node
  71762. */
  71763. metadata: any;
  71764. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71765. isHitTestVisible: boolean;
  71766. /** Gets or sets a boolean indicating if the control can block pointer events */
  71767. isPointerBlocker: boolean;
  71768. /** Gets or sets a boolean indicating if the control can be focusable */
  71769. isFocusInvisible: boolean;
  71770. /**
  71771. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71772. * 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
  71773. */
  71774. clipChildren: boolean;
  71775. /**
  71776. * Gets or sets a boolean indicating that control content must be clipped
  71777. * 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
  71778. */
  71779. clipContent: boolean;
  71780. /**
  71781. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71782. */
  71783. useBitmapCache: boolean;
  71784. private _cacheData;
  71785. private _shadowOffsetX;
  71786. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71787. get shadowOffsetX(): number;
  71788. set shadowOffsetX(value: number);
  71789. private _shadowOffsetY;
  71790. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71791. get shadowOffsetY(): number;
  71792. set shadowOffsetY(value: number);
  71793. private _shadowBlur;
  71794. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71795. get shadowBlur(): number;
  71796. set shadowBlur(value: number);
  71797. private _shadowColor;
  71798. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71799. get shadowColor(): string;
  71800. set shadowColor(value: string);
  71801. /** Gets or sets the cursor to use when the control is hovered */
  71802. hoverCursor: string;
  71803. /** @hidden */
  71804. protected _linkOffsetX: ValueAndUnit;
  71805. /** @hidden */
  71806. protected _linkOffsetY: ValueAndUnit;
  71807. /** Gets the control type name */
  71808. get typeName(): string;
  71809. /**
  71810. * Get the current class name of the control.
  71811. * @returns current class name
  71812. */
  71813. getClassName(): string;
  71814. /**
  71815. * An event triggered when pointer wheel is scrolled
  71816. */
  71817. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71818. /**
  71819. * An event triggered when the pointer move over the control.
  71820. */
  71821. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71822. /**
  71823. * An event triggered when the pointer move out of the control.
  71824. */
  71825. onPointerOutObservable: BABYLON.Observable<Control>;
  71826. /**
  71827. * An event triggered when the pointer taps the control
  71828. */
  71829. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71830. /**
  71831. * An event triggered when pointer up
  71832. */
  71833. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71834. /**
  71835. * An event triggered when a control is clicked on
  71836. */
  71837. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71838. /**
  71839. * An event triggered when pointer enters the control
  71840. */
  71841. onPointerEnterObservable: BABYLON.Observable<Control>;
  71842. /**
  71843. * An event triggered when the control is marked as dirty
  71844. */
  71845. onDirtyObservable: BABYLON.Observable<Control>;
  71846. /**
  71847. * An event triggered before drawing the control
  71848. */
  71849. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71850. /**
  71851. * An event triggered after the control was drawn
  71852. */
  71853. onAfterDrawObservable: BABYLON.Observable<Control>;
  71854. /**
  71855. * Get the hosting AdvancedDynamicTexture
  71856. */
  71857. get host(): AdvancedDynamicTexture;
  71858. /** Gets or set information about font offsets (used to render and align text) */
  71859. get fontOffset(): {
  71860. ascent: number;
  71861. height: number;
  71862. descent: number;
  71863. };
  71864. set fontOffset(offset: {
  71865. ascent: number;
  71866. height: number;
  71867. descent: number;
  71868. });
  71869. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71870. get alpha(): number;
  71871. set alpha(value: number);
  71872. /**
  71873. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71874. */
  71875. get isHighlighted(): boolean;
  71876. set isHighlighted(value: boolean);
  71877. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71879. */
  71880. get scaleX(): number;
  71881. set scaleX(value: number);
  71882. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71883. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71884. */
  71885. get scaleY(): number;
  71886. set scaleY(value: number);
  71887. /** Gets or sets the rotation angle (0 by default)
  71888. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71889. */
  71890. get rotation(): number;
  71891. set rotation(value: number);
  71892. /** Gets or sets the transformation center on Y axis (0 by default)
  71893. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71894. */
  71895. get transformCenterY(): number;
  71896. set transformCenterY(value: number);
  71897. /** Gets or sets the transformation center on X axis (0 by default)
  71898. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71899. */
  71900. get transformCenterX(): number;
  71901. set transformCenterX(value: number);
  71902. /**
  71903. * Gets or sets the horizontal alignment
  71904. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71905. */
  71906. get horizontalAlignment(): number;
  71907. set horizontalAlignment(value: number);
  71908. /**
  71909. * Gets or sets the vertical alignment
  71910. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71911. */
  71912. get verticalAlignment(): number;
  71913. set verticalAlignment(value: number);
  71914. /**
  71915. * Gets or sets control width
  71916. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71917. */
  71918. get width(): string | number;
  71919. set width(value: string | number);
  71920. /**
  71921. * Gets or sets the control width in pixel
  71922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71923. */
  71924. get widthInPixels(): number;
  71925. set widthInPixels(value: number);
  71926. /**
  71927. * Gets or sets control height
  71928. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71929. */
  71930. get height(): string | number;
  71931. set height(value: string | number);
  71932. /**
  71933. * Gets or sets control height in pixel
  71934. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71935. */
  71936. get heightInPixels(): number;
  71937. set heightInPixels(value: number);
  71938. /** Gets or set font family */
  71939. get fontFamily(): string;
  71940. set fontFamily(value: string);
  71941. /** Gets or sets font style */
  71942. get fontStyle(): string;
  71943. set fontStyle(value: string);
  71944. /** Gets or sets font weight */
  71945. get fontWeight(): string;
  71946. set fontWeight(value: string);
  71947. /**
  71948. * Gets or sets style
  71949. * @see http://doc.babylonjs.com/how_to/gui#styles
  71950. */
  71951. get style(): BABYLON.Nullable<Style>;
  71952. set style(value: BABYLON.Nullable<Style>);
  71953. /** @hidden */
  71954. get _isFontSizeInPercentage(): boolean;
  71955. /** Gets or sets font size in pixels */
  71956. get fontSizeInPixels(): number;
  71957. set fontSizeInPixels(value: number);
  71958. /** Gets or sets font size */
  71959. get fontSize(): string | number;
  71960. set fontSize(value: string | number);
  71961. /** Gets or sets foreground color */
  71962. get color(): string;
  71963. set color(value: string);
  71964. /** Gets or sets z index which is used to reorder controls on the z axis */
  71965. get zIndex(): number;
  71966. set zIndex(value: number);
  71967. /** Gets or sets a boolean indicating if the control can be rendered */
  71968. get notRenderable(): boolean;
  71969. set notRenderable(value: boolean);
  71970. /** Gets or sets a boolean indicating if the control is visible */
  71971. get isVisible(): boolean;
  71972. set isVisible(value: boolean);
  71973. /** Gets a boolean indicating that the control needs to update its rendering */
  71974. get isDirty(): boolean;
  71975. /**
  71976. * Gets the current linked mesh (or null if none)
  71977. */
  71978. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71979. /**
  71980. * Gets or sets a value indicating the padding to use on the left of the control
  71981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71982. */
  71983. get paddingLeft(): string | number;
  71984. set paddingLeft(value: string | number);
  71985. /**
  71986. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71987. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71988. */
  71989. get paddingLeftInPixels(): number;
  71990. set paddingLeftInPixels(value: number);
  71991. /**
  71992. * Gets or sets a value indicating the padding to use on the right of the control
  71993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71994. */
  71995. get paddingRight(): string | number;
  71996. set paddingRight(value: string | number);
  71997. /**
  71998. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71999. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72000. */
  72001. get paddingRightInPixels(): number;
  72002. set paddingRightInPixels(value: number);
  72003. /**
  72004. * Gets or sets a value indicating the padding to use on the top of the control
  72005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72006. */
  72007. get paddingTop(): string | number;
  72008. set paddingTop(value: string | number);
  72009. /**
  72010. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72011. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72012. */
  72013. get paddingTopInPixels(): number;
  72014. set paddingTopInPixels(value: number);
  72015. /**
  72016. * Gets or sets a value indicating the padding to use on the bottom of the control
  72017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72018. */
  72019. get paddingBottom(): string | number;
  72020. set paddingBottom(value: string | number);
  72021. /**
  72022. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72024. */
  72025. get paddingBottomInPixels(): number;
  72026. set paddingBottomInPixels(value: number);
  72027. /**
  72028. * Gets or sets a value indicating the left coordinate of the control
  72029. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72030. */
  72031. get left(): string | number;
  72032. set left(value: string | number);
  72033. /**
  72034. * Gets or sets a value indicating the left coordinate in pixels of the control
  72035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72036. */
  72037. get leftInPixels(): number;
  72038. set leftInPixels(value: number);
  72039. /**
  72040. * Gets or sets a value indicating the top coordinate of the control
  72041. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72042. */
  72043. get top(): string | number;
  72044. set top(value: string | number);
  72045. /**
  72046. * Gets or sets a value indicating the top coordinate in pixels of the control
  72047. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72048. */
  72049. get topInPixels(): number;
  72050. set topInPixels(value: number);
  72051. /**
  72052. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72053. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72054. */
  72055. get linkOffsetX(): string | number;
  72056. set linkOffsetX(value: string | number);
  72057. /**
  72058. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72059. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72060. */
  72061. get linkOffsetXInPixels(): number;
  72062. set linkOffsetXInPixels(value: number);
  72063. /**
  72064. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72065. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72066. */
  72067. get linkOffsetY(): string | number;
  72068. set linkOffsetY(value: string | number);
  72069. /**
  72070. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72071. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72072. */
  72073. get linkOffsetYInPixels(): number;
  72074. set linkOffsetYInPixels(value: number);
  72075. /** Gets the center coordinate on X axis */
  72076. get centerX(): number;
  72077. /** Gets the center coordinate on Y axis */
  72078. get centerY(): number;
  72079. /** Gets or sets if control is Enabled*/
  72080. get isEnabled(): boolean;
  72081. set isEnabled(value: boolean);
  72082. /** Gets or sets background color of control if it's disabled*/
  72083. get disabledColor(): string;
  72084. set disabledColor(value: string);
  72085. /** Gets or sets front color of control if it's disabled*/
  72086. get disabledColorItem(): string;
  72087. set disabledColorItem(value: string);
  72088. /**
  72089. * Creates a new control
  72090. * @param name defines the name of the control
  72091. */
  72092. constructor(
  72093. /** defines the name of the control */
  72094. name?: string | undefined);
  72095. /** @hidden */
  72096. protected _getTypeName(): string;
  72097. /**
  72098. * Gets the first ascendant in the hierarchy of the given type
  72099. * @param className defines the required type
  72100. * @returns the ascendant or null if not found
  72101. */
  72102. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72103. /** @hidden */
  72104. _resetFontCache(): void;
  72105. /**
  72106. * Determines if a container is an ascendant of the current control
  72107. * @param container defines the container to look for
  72108. * @returns true if the container is one of the ascendant of the control
  72109. */
  72110. isAscendant(container: Control): boolean;
  72111. /**
  72112. * Gets coordinates in local control space
  72113. * @param globalCoordinates defines the coordinates to transform
  72114. * @returns the new coordinates in local space
  72115. */
  72116. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72117. /**
  72118. * Gets coordinates in local control space
  72119. * @param globalCoordinates defines the coordinates to transform
  72120. * @param result defines the target vector2 where to store the result
  72121. * @returns the current control
  72122. */
  72123. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72124. /**
  72125. * Gets coordinates in parent local control space
  72126. * @param globalCoordinates defines the coordinates to transform
  72127. * @returns the new coordinates in parent local space
  72128. */
  72129. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72130. /**
  72131. * Move the current control to a vector3 position projected onto the screen.
  72132. * @param position defines the target position
  72133. * @param scene defines the hosting scene
  72134. */
  72135. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72136. /**
  72137. * Will store all controls that have this control as ascendant in a given array
  72138. * @param results defines the array where to store the descendants
  72139. * @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
  72140. * @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
  72141. */
  72142. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72143. /**
  72144. * Will return all controls that have this control as ascendant
  72145. * @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
  72146. * @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
  72147. * @return all child controls
  72148. */
  72149. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72150. /**
  72151. * Link current control with a target mesh
  72152. * @param mesh defines the mesh to link with
  72153. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72154. */
  72155. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72156. /** @hidden */
  72157. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72158. /** @hidden */
  72159. _offsetLeft(offset: number): void;
  72160. /** @hidden */
  72161. _offsetTop(offset: number): void;
  72162. /** @hidden */
  72163. _markMatrixAsDirty(): void;
  72164. /** @hidden */
  72165. _flagDescendantsAsMatrixDirty(): void;
  72166. /** @hidden */
  72167. _intersectsRect(rect: Measure): boolean;
  72168. /** @hidden */
  72169. protected invalidateRect(): void;
  72170. /** @hidden */
  72171. _markAsDirty(force?: boolean): void;
  72172. /** @hidden */
  72173. _markAllAsDirty(): void;
  72174. /** @hidden */
  72175. _link(host: AdvancedDynamicTexture): void;
  72176. /** @hidden */
  72177. protected _transform(context?: CanvasRenderingContext2D): void;
  72178. /** @hidden */
  72179. _renderHighlight(context: CanvasRenderingContext2D): void;
  72180. /** @hidden */
  72181. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72182. /** @hidden */
  72183. protected _applyStates(context: CanvasRenderingContext2D): void;
  72184. /** @hidden */
  72185. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72186. /** @hidden */
  72187. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72188. protected _evaluateClippingState(parentMeasure: Measure): void;
  72189. /** @hidden */
  72190. _measure(): void;
  72191. /** @hidden */
  72192. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72193. /** @hidden */
  72194. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72195. /** @hidden */
  72196. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72197. /** @hidden */
  72198. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72199. private static _ClipMeasure;
  72200. private _tmpMeasureA;
  72201. private _clip;
  72202. /** @hidden */
  72203. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72204. /** @hidden */
  72205. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72206. /**
  72207. * Tests if a given coordinates belong to the current control
  72208. * @param x defines x coordinate to test
  72209. * @param y defines y coordinate to test
  72210. * @returns true if the coordinates are inside the control
  72211. */
  72212. contains(x: number, y: number): boolean;
  72213. /** @hidden */
  72214. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72215. /** @hidden */
  72216. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72217. /** @hidden */
  72218. _onPointerEnter(target: Control): boolean;
  72219. /** @hidden */
  72220. _onPointerOut(target: Control, force?: boolean): void;
  72221. /** @hidden */
  72222. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72223. /** @hidden */
  72224. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72225. /** @hidden */
  72226. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72227. /** @hidden */
  72228. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72229. /** @hidden */
  72230. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72231. private _prepareFont;
  72232. /** Releases associated resources */
  72233. dispose(): void;
  72234. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72235. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72236. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72237. private static _VERTICAL_ALIGNMENT_TOP;
  72238. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72239. private static _VERTICAL_ALIGNMENT_CENTER;
  72240. /** HORIZONTAL_ALIGNMENT_LEFT */
  72241. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72242. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72243. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72244. /** HORIZONTAL_ALIGNMENT_CENTER */
  72245. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72246. /** VERTICAL_ALIGNMENT_TOP */
  72247. static get VERTICAL_ALIGNMENT_TOP(): number;
  72248. /** VERTICAL_ALIGNMENT_BOTTOM */
  72249. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72250. /** VERTICAL_ALIGNMENT_CENTER */
  72251. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72252. private static _FontHeightSizes;
  72253. /** @hidden */
  72254. static _GetFontOffset(font: string): {
  72255. ascent: number;
  72256. height: number;
  72257. descent: number;
  72258. };
  72259. /**
  72260. * Creates a stack panel that can be used to render headers
  72261. * @param control defines the control to associate with the header
  72262. * @param text defines the text of the header
  72263. * @param size defines the size of the header
  72264. * @param options defines options used to configure the header
  72265. * @returns a new StackPanel
  72266. * @ignore
  72267. * @hidden
  72268. */
  72269. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72270. isHorizontal: boolean;
  72271. controlFirst: boolean;
  72272. }) => any;
  72273. /** @hidden */
  72274. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72275. }
  72276. }
  72277. declare module BABYLON.GUI {
  72278. /**
  72279. * Root class for 2D containers
  72280. * @see http://doc.babylonjs.com/how_to/gui#containers
  72281. */
  72282. export class Container extends Control {
  72283. name?: string | undefined;
  72284. /** @hidden */
  72285. _children: Control[];
  72286. /** @hidden */
  72287. protected _measureForChildren: Measure;
  72288. /** @hidden */
  72289. protected _background: string;
  72290. /** @hidden */
  72291. protected _adaptWidthToChildren: boolean;
  72292. /** @hidden */
  72293. protected _adaptHeightToChildren: boolean;
  72294. /**
  72295. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72296. */
  72297. logLayoutCycleErrors: boolean;
  72298. /**
  72299. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72300. */
  72301. maxLayoutCycle: number;
  72302. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72303. get adaptHeightToChildren(): boolean;
  72304. set adaptHeightToChildren(value: boolean);
  72305. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72306. get adaptWidthToChildren(): boolean;
  72307. set adaptWidthToChildren(value: boolean);
  72308. /** Gets or sets background color */
  72309. get background(): string;
  72310. set background(value: string);
  72311. /** Gets the list of children */
  72312. get children(): Control[];
  72313. /**
  72314. * Creates a new Container
  72315. * @param name defines the name of the container
  72316. */
  72317. constructor(name?: string | undefined);
  72318. protected _getTypeName(): string;
  72319. _flagDescendantsAsMatrixDirty(): void;
  72320. /**
  72321. * Gets a child using its name
  72322. * @param name defines the child name to look for
  72323. * @returns the child control if found
  72324. */
  72325. getChildByName(name: string): BABYLON.Nullable<Control>;
  72326. /**
  72327. * Gets a child using its type and its name
  72328. * @param name defines the child name to look for
  72329. * @param type defines the child type to look for
  72330. * @returns the child control if found
  72331. */
  72332. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72333. /**
  72334. * Search for a specific control in children
  72335. * @param control defines the control to look for
  72336. * @returns true if the control is in child list
  72337. */
  72338. containsControl(control: Control): boolean;
  72339. /**
  72340. * Adds a new control to the current container
  72341. * @param control defines the control to add
  72342. * @returns the current container
  72343. */
  72344. addControl(control: BABYLON.Nullable<Control>): Container;
  72345. /**
  72346. * Removes all controls from the current container
  72347. * @returns the current container
  72348. */
  72349. clearControls(): Container;
  72350. /**
  72351. * Removes a control from the current container
  72352. * @param control defines the control to remove
  72353. * @returns the current container
  72354. */
  72355. removeControl(control: Control): Container;
  72356. /** @hidden */
  72357. _reOrderControl(control: Control): void;
  72358. /** @hidden */
  72359. _offsetLeft(offset: number): void;
  72360. /** @hidden */
  72361. _offsetTop(offset: number): void;
  72362. /** @hidden */
  72363. _markAllAsDirty(): void;
  72364. /** @hidden */
  72365. protected _localDraw(context: CanvasRenderingContext2D): void;
  72366. /** @hidden */
  72367. _link(host: AdvancedDynamicTexture): void;
  72368. /** @hidden */
  72369. protected _beforeLayout(): void;
  72370. /** @hidden */
  72371. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72372. /** @hidden */
  72373. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72374. protected _postMeasure(): void;
  72375. /** @hidden */
  72376. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72377. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72378. /** @hidden */
  72379. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72380. /** @hidden */
  72381. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72382. /** Releases associated resources */
  72383. dispose(): void;
  72384. }
  72385. }
  72386. declare module BABYLON.GUI {
  72387. /** Class used to create rectangle container */
  72388. export class Rectangle extends Container {
  72389. name?: string | undefined;
  72390. private _thickness;
  72391. private _cornerRadius;
  72392. /** Gets or sets border thickness */
  72393. get thickness(): number;
  72394. set thickness(value: number);
  72395. /** Gets or sets the corner radius angle */
  72396. get cornerRadius(): number;
  72397. set cornerRadius(value: number);
  72398. /**
  72399. * Creates a new Rectangle
  72400. * @param name defines the control name
  72401. */
  72402. constructor(name?: string | undefined);
  72403. protected _getTypeName(): string;
  72404. protected _localDraw(context: CanvasRenderingContext2D): void;
  72405. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72406. private _drawRoundedRect;
  72407. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72408. }
  72409. }
  72410. declare module BABYLON.GUI {
  72411. /**
  72412. * Enum that determines the text-wrapping mode to use.
  72413. */
  72414. export enum TextWrapping {
  72415. /**
  72416. * Clip the text when it's larger than Control.width; this is the default mode.
  72417. */
  72418. Clip = 0,
  72419. /**
  72420. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72421. */
  72422. WordWrap = 1,
  72423. /**
  72424. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72425. */
  72426. Ellipsis = 2
  72427. }
  72428. /**
  72429. * Class used to create text block control
  72430. */
  72431. export class TextBlock extends Control {
  72432. /**
  72433. * Defines the name of the control
  72434. */
  72435. name?: string | undefined;
  72436. private _text;
  72437. private _textWrapping;
  72438. private _textHorizontalAlignment;
  72439. private _textVerticalAlignment;
  72440. private _lines;
  72441. private _resizeToFit;
  72442. private _lineSpacing;
  72443. private _outlineWidth;
  72444. private _outlineColor;
  72445. /**
  72446. * An event triggered after the text is changed
  72447. */
  72448. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72449. /**
  72450. * An event triggered after the text was broken up into lines
  72451. */
  72452. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72453. /**
  72454. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72455. */
  72456. get lines(): any[];
  72457. /**
  72458. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72459. */
  72460. get resizeToFit(): boolean;
  72461. /**
  72462. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72463. */
  72464. set resizeToFit(value: boolean);
  72465. /**
  72466. * Gets or sets a boolean indicating if text must be wrapped
  72467. */
  72468. get textWrapping(): TextWrapping | boolean;
  72469. /**
  72470. * Gets or sets a boolean indicating if text must be wrapped
  72471. */
  72472. set textWrapping(value: TextWrapping | boolean);
  72473. /**
  72474. * Gets or sets text to display
  72475. */
  72476. get text(): string;
  72477. /**
  72478. * Gets or sets text to display
  72479. */
  72480. set text(value: string);
  72481. /**
  72482. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72483. */
  72484. get textHorizontalAlignment(): number;
  72485. /**
  72486. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72487. */
  72488. set textHorizontalAlignment(value: number);
  72489. /**
  72490. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72491. */
  72492. get textVerticalAlignment(): number;
  72493. /**
  72494. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72495. */
  72496. set textVerticalAlignment(value: number);
  72497. /**
  72498. * Gets or sets line spacing value
  72499. */
  72500. set lineSpacing(value: string | number);
  72501. /**
  72502. * Gets or sets line spacing value
  72503. */
  72504. get lineSpacing(): string | number;
  72505. /**
  72506. * Gets or sets outlineWidth of the text to display
  72507. */
  72508. get outlineWidth(): number;
  72509. /**
  72510. * Gets or sets outlineWidth of the text to display
  72511. */
  72512. set outlineWidth(value: number);
  72513. /**
  72514. * Gets or sets outlineColor of the text to display
  72515. */
  72516. get outlineColor(): string;
  72517. /**
  72518. * Gets or sets outlineColor of the text to display
  72519. */
  72520. set outlineColor(value: string);
  72521. /**
  72522. * Creates a new TextBlock object
  72523. * @param name defines the name of the control
  72524. * @param text defines the text to display (emptry string by default)
  72525. */
  72526. constructor(
  72527. /**
  72528. * Defines the name of the control
  72529. */
  72530. name?: string | undefined, text?: string);
  72531. protected _getTypeName(): string;
  72532. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72533. private _drawText;
  72534. /** @hidden */
  72535. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72536. protected _applyStates(context: CanvasRenderingContext2D): void;
  72537. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72538. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72539. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72540. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72541. protected _renderLines(context: CanvasRenderingContext2D): void;
  72542. /**
  72543. * Given a width constraint applied on the text block, find the expected height
  72544. * @returns expected height
  72545. */
  72546. computeExpectedHeight(): number;
  72547. dispose(): void;
  72548. }
  72549. }
  72550. declare module BABYLON.GUI {
  72551. /**
  72552. * Class used to create 2D images
  72553. */
  72554. export class Image extends Control {
  72555. name?: string | undefined;
  72556. private _workingCanvas;
  72557. private _domImage;
  72558. private _imageWidth;
  72559. private _imageHeight;
  72560. private _loaded;
  72561. private _stretch;
  72562. private _source;
  72563. private _autoScale;
  72564. private _sourceLeft;
  72565. private _sourceTop;
  72566. private _sourceWidth;
  72567. private _sourceHeight;
  72568. private _svgAttributesComputationCompleted;
  72569. private _isSVG;
  72570. private _cellWidth;
  72571. private _cellHeight;
  72572. private _cellId;
  72573. private _populateNinePatchSlicesFromImage;
  72574. private _sliceLeft;
  72575. private _sliceRight;
  72576. private _sliceTop;
  72577. private _sliceBottom;
  72578. private _detectPointerOnOpaqueOnly;
  72579. /**
  72580. * BABYLON.Observable notified when the content is loaded
  72581. */
  72582. onImageLoadedObservable: BABYLON.Observable<Image>;
  72583. /**
  72584. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72585. */
  72586. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72587. /**
  72588. * Gets a boolean indicating that the content is loaded
  72589. */
  72590. get isLoaded(): boolean;
  72591. /**
  72592. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72593. */
  72594. get populateNinePatchSlicesFromImage(): boolean;
  72595. set populateNinePatchSlicesFromImage(value: boolean);
  72596. /**
  72597. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72598. * Beware using this as this will comsume more memory as the image has to be stored twice
  72599. */
  72600. get detectPointerOnOpaqueOnly(): boolean;
  72601. set detectPointerOnOpaqueOnly(value: boolean);
  72602. /**
  72603. * Gets or sets the left value for slicing (9-patch)
  72604. */
  72605. get sliceLeft(): number;
  72606. set sliceLeft(value: number);
  72607. /**
  72608. * Gets or sets the right value for slicing (9-patch)
  72609. */
  72610. get sliceRight(): number;
  72611. set sliceRight(value: number);
  72612. /**
  72613. * Gets or sets the top value for slicing (9-patch)
  72614. */
  72615. get sliceTop(): number;
  72616. set sliceTop(value: number);
  72617. /**
  72618. * Gets or sets the bottom value for slicing (9-patch)
  72619. */
  72620. get sliceBottom(): number;
  72621. set sliceBottom(value: number);
  72622. /**
  72623. * Gets or sets the left coordinate in the source image
  72624. */
  72625. get sourceLeft(): number;
  72626. set sourceLeft(value: number);
  72627. /**
  72628. * Gets or sets the top coordinate in the source image
  72629. */
  72630. get sourceTop(): number;
  72631. set sourceTop(value: number);
  72632. /**
  72633. * Gets or sets the width to capture in the source image
  72634. */
  72635. get sourceWidth(): number;
  72636. set sourceWidth(value: number);
  72637. /**
  72638. * Gets or sets the height to capture in the source image
  72639. */
  72640. get sourceHeight(): number;
  72641. set sourceHeight(value: number);
  72642. /** Indicates if the format of the image is SVG */
  72643. get isSVG(): boolean;
  72644. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72645. get svgAttributesComputationCompleted(): boolean;
  72646. /**
  72647. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72648. * @see http://doc.babylonjs.com/how_to/gui#image
  72649. */
  72650. get autoScale(): boolean;
  72651. set autoScale(value: boolean);
  72652. /** Gets or sets the streching mode used by the image */
  72653. get stretch(): number;
  72654. set stretch(value: number);
  72655. /** @hidden */
  72656. _rotate90(n: number, preserveProperties?: boolean): Image;
  72657. private _handleRotationForSVGImage;
  72658. private _rotate90SourceProperties;
  72659. /**
  72660. * Gets or sets the internal DOM image used to render the control
  72661. */
  72662. set domImage(value: HTMLImageElement);
  72663. get domImage(): HTMLImageElement;
  72664. private _onImageLoaded;
  72665. private _extractNinePatchSliceDataFromImage;
  72666. /**
  72667. * Gets or sets image source url
  72668. */
  72669. set source(value: BABYLON.Nullable<string>);
  72670. /**
  72671. * Checks for svg document with icon id present
  72672. */
  72673. private _svgCheck;
  72674. /**
  72675. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72676. * given external svg file and icon id
  72677. */
  72678. private _getSVGAttribs;
  72679. /**
  72680. * Gets or sets the cell width to use when animation sheet is enabled
  72681. * @see http://doc.babylonjs.com/how_to/gui#image
  72682. */
  72683. get cellWidth(): number;
  72684. set cellWidth(value: number);
  72685. /**
  72686. * Gets or sets the cell height to use when animation sheet is enabled
  72687. * @see http://doc.babylonjs.com/how_to/gui#image
  72688. */
  72689. get cellHeight(): number;
  72690. set cellHeight(value: number);
  72691. /**
  72692. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72693. * @see http://doc.babylonjs.com/how_to/gui#image
  72694. */
  72695. get cellId(): number;
  72696. set cellId(value: number);
  72697. /**
  72698. * Creates a new Image
  72699. * @param name defines the control name
  72700. * @param url defines the image url
  72701. */
  72702. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72703. /**
  72704. * Tests if a given coordinates belong to the current control
  72705. * @param x defines x coordinate to test
  72706. * @param y defines y coordinate to test
  72707. * @returns true if the coordinates are inside the control
  72708. */
  72709. contains(x: number, y: number): boolean;
  72710. protected _getTypeName(): string;
  72711. /** Force the control to synchronize with its content */
  72712. synchronizeSizeWithContent(): void;
  72713. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72714. private _prepareWorkingCanvasForOpaqueDetection;
  72715. private _drawImage;
  72716. _draw(context: CanvasRenderingContext2D): void;
  72717. private _renderCornerPatch;
  72718. private _renderNinePatch;
  72719. dispose(): void;
  72720. /** STRETCH_NONE */
  72721. static readonly STRETCH_NONE: number;
  72722. /** STRETCH_FILL */
  72723. static readonly STRETCH_FILL: number;
  72724. /** STRETCH_UNIFORM */
  72725. static readonly STRETCH_UNIFORM: number;
  72726. /** STRETCH_EXTEND */
  72727. static readonly STRETCH_EXTEND: number;
  72728. /** NINE_PATCH */
  72729. static readonly STRETCH_NINE_PATCH: number;
  72730. }
  72731. }
  72732. declare module BABYLON.GUI {
  72733. /**
  72734. * Class used to create 2D buttons
  72735. */
  72736. export class Button extends Rectangle {
  72737. name?: string | undefined;
  72738. /**
  72739. * Function called to generate a pointer enter animation
  72740. */
  72741. pointerEnterAnimation: () => void;
  72742. /**
  72743. * Function called to generate a pointer out animation
  72744. */
  72745. pointerOutAnimation: () => void;
  72746. /**
  72747. * Function called to generate a pointer down animation
  72748. */
  72749. pointerDownAnimation: () => void;
  72750. /**
  72751. * Function called to generate a pointer up animation
  72752. */
  72753. pointerUpAnimation: () => void;
  72754. /**
  72755. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72756. */
  72757. delegatePickingToChildren: boolean;
  72758. private _image;
  72759. /**
  72760. * Returns the image part of the button (if any)
  72761. */
  72762. get image(): BABYLON.Nullable<Image>;
  72763. private _textBlock;
  72764. /**
  72765. * Returns the image part of the button (if any)
  72766. */
  72767. get textBlock(): BABYLON.Nullable<TextBlock>;
  72768. /**
  72769. * Creates a new Button
  72770. * @param name defines the name of the button
  72771. */
  72772. constructor(name?: string | undefined);
  72773. protected _getTypeName(): string;
  72774. /** @hidden */
  72775. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72776. /** @hidden */
  72777. _onPointerEnter(target: Control): boolean;
  72778. /** @hidden */
  72779. _onPointerOut(target: Control, force?: boolean): void;
  72780. /** @hidden */
  72781. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72782. /** @hidden */
  72783. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72784. /**
  72785. * Creates a new button made with an image and a text
  72786. * @param name defines the name of the button
  72787. * @param text defines the text of the button
  72788. * @param imageUrl defines the url of the image
  72789. * @returns a new Button
  72790. */
  72791. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72792. /**
  72793. * Creates a new button made with an image
  72794. * @param name defines the name of the button
  72795. * @param imageUrl defines the url of the image
  72796. * @returns a new Button
  72797. */
  72798. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72799. /**
  72800. * Creates a new button made with a text
  72801. * @param name defines the name of the button
  72802. * @param text defines the text of the button
  72803. * @returns a new Button
  72804. */
  72805. static CreateSimpleButton(name: string, text: string): Button;
  72806. /**
  72807. * Creates a new button made with an image and a centered text
  72808. * @param name defines the name of the button
  72809. * @param text defines the text of the button
  72810. * @param imageUrl defines the url of the image
  72811. * @returns a new Button
  72812. */
  72813. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72814. }
  72815. }
  72816. declare module BABYLON.GUI {
  72817. /**
  72818. * Class used to create a 2D stack panel container
  72819. */
  72820. export class StackPanel extends Container {
  72821. name?: string | undefined;
  72822. private _isVertical;
  72823. private _manualWidth;
  72824. private _manualHeight;
  72825. private _doNotTrackManualChanges;
  72826. /**
  72827. * Gets or sets a boolean indicating that layou warnings should be ignored
  72828. */
  72829. ignoreLayoutWarnings: boolean;
  72830. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72831. get isVertical(): boolean;
  72832. set isVertical(value: boolean);
  72833. /**
  72834. * Gets or sets panel width.
  72835. * This value should not be set when in horizontal mode as it will be computed automatically
  72836. */
  72837. set width(value: string | number);
  72838. get width(): string | number;
  72839. /**
  72840. * Gets or sets panel height.
  72841. * This value should not be set when in vertical mode as it will be computed automatically
  72842. */
  72843. set height(value: string | number);
  72844. get height(): string | number;
  72845. /**
  72846. * Creates a new StackPanel
  72847. * @param name defines control name
  72848. */
  72849. constructor(name?: string | undefined);
  72850. protected _getTypeName(): string;
  72851. /** @hidden */
  72852. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72853. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72854. protected _postMeasure(): void;
  72855. }
  72856. }
  72857. declare module BABYLON.GUI {
  72858. /**
  72859. * Class used to represent a 2D checkbox
  72860. */
  72861. export class Checkbox extends Control {
  72862. name?: string | undefined;
  72863. private _isChecked;
  72864. private _background;
  72865. private _checkSizeRatio;
  72866. private _thickness;
  72867. /** Gets or sets border thickness */
  72868. get thickness(): number;
  72869. set thickness(value: number);
  72870. /**
  72871. * BABYLON.Observable raised when isChecked property changes
  72872. */
  72873. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72874. /** Gets or sets a value indicating the ratio between overall size and check size */
  72875. get checkSizeRatio(): number;
  72876. set checkSizeRatio(value: number);
  72877. /** Gets or sets background color */
  72878. get background(): string;
  72879. set background(value: string);
  72880. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72881. get isChecked(): boolean;
  72882. set isChecked(value: boolean);
  72883. /**
  72884. * Creates a new CheckBox
  72885. * @param name defines the control name
  72886. */
  72887. constructor(name?: string | undefined);
  72888. protected _getTypeName(): string;
  72889. /** @hidden */
  72890. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72891. /** @hidden */
  72892. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72893. /**
  72894. * Utility function to easily create a checkbox with a header
  72895. * @param title defines the label to use for the header
  72896. * @param onValueChanged defines the callback to call when value changes
  72897. * @returns a StackPanel containing the checkbox and a textBlock
  72898. */
  72899. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72900. }
  72901. }
  72902. declare module BABYLON.GUI {
  72903. /**
  72904. * Class used to store key control properties
  72905. */
  72906. export class KeyPropertySet {
  72907. /** Width */
  72908. width?: string;
  72909. /** Height */
  72910. height?: string;
  72911. /** Left padding */
  72912. paddingLeft?: string;
  72913. /** Right padding */
  72914. paddingRight?: string;
  72915. /** Top padding */
  72916. paddingTop?: string;
  72917. /** Bottom padding */
  72918. paddingBottom?: string;
  72919. /** Foreground color */
  72920. color?: string;
  72921. /** Background color */
  72922. background?: string;
  72923. }
  72924. /**
  72925. * Class used to create virtual keyboard
  72926. */
  72927. export class VirtualKeyboard extends StackPanel {
  72928. /** BABYLON.Observable raised when a key is pressed */
  72929. onKeyPressObservable: BABYLON.Observable<string>;
  72930. /** Gets or sets default key button width */
  72931. defaultButtonWidth: string;
  72932. /** Gets or sets default key button height */
  72933. defaultButtonHeight: string;
  72934. /** Gets or sets default key button left padding */
  72935. defaultButtonPaddingLeft: string;
  72936. /** Gets or sets default key button right padding */
  72937. defaultButtonPaddingRight: string;
  72938. /** Gets or sets default key button top padding */
  72939. defaultButtonPaddingTop: string;
  72940. /** Gets or sets default key button bottom padding */
  72941. defaultButtonPaddingBottom: string;
  72942. /** Gets or sets default key button foreground color */
  72943. defaultButtonColor: string;
  72944. /** Gets or sets default key button background color */
  72945. defaultButtonBackground: string;
  72946. /** Gets or sets shift button foreground color */
  72947. shiftButtonColor: string;
  72948. /** Gets or sets shift button thickness*/
  72949. selectedShiftThickness: number;
  72950. /** Gets shift key state */
  72951. shiftState: number;
  72952. protected _getTypeName(): string;
  72953. private _createKey;
  72954. /**
  72955. * Adds a new row of keys
  72956. * @param keys defines the list of keys to add
  72957. * @param propertySets defines the associated property sets
  72958. */
  72959. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72960. /**
  72961. * Set the shift key to a specific state
  72962. * @param shiftState defines the new shift state
  72963. */
  72964. applyShiftState(shiftState: number): void;
  72965. private _currentlyConnectedInputText;
  72966. private _connectedInputTexts;
  72967. private _onKeyPressObserver;
  72968. /** Gets the input text control currently attached to the keyboard */
  72969. get connectedInputText(): BABYLON.Nullable<InputText>;
  72970. /**
  72971. * Connects the keyboard with an input text control
  72972. *
  72973. * @param input defines the target control
  72974. */
  72975. connect(input: InputText): void;
  72976. /**
  72977. * Disconnects the keyboard from connected InputText controls
  72978. *
  72979. * @param input optionally defines a target control, otherwise all are disconnected
  72980. */
  72981. disconnect(input?: InputText): void;
  72982. private _removeConnectedInputObservables;
  72983. /**
  72984. * Release all resources
  72985. */
  72986. dispose(): void;
  72987. /**
  72988. * Creates a new keyboard using a default layout
  72989. *
  72990. * @param name defines control name
  72991. * @returns a new VirtualKeyboard
  72992. */
  72993. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72994. }
  72995. }
  72996. declare module BABYLON.GUI {
  72997. /**
  72998. * Class used to create input text control
  72999. */
  73000. export class InputText extends Control implements IFocusableControl {
  73001. name?: string | undefined;
  73002. private _text;
  73003. private _placeholderText;
  73004. private _background;
  73005. private _focusedBackground;
  73006. private _focusedColor;
  73007. private _placeholderColor;
  73008. private _thickness;
  73009. private _margin;
  73010. private _autoStretchWidth;
  73011. private _maxWidth;
  73012. private _isFocused;
  73013. private _blinkTimeout;
  73014. private _blinkIsEven;
  73015. private _cursorOffset;
  73016. private _scrollLeft;
  73017. private _textWidth;
  73018. private _clickedCoordinate;
  73019. private _deadKey;
  73020. private _addKey;
  73021. private _currentKey;
  73022. private _isTextHighlightOn;
  73023. private _textHighlightColor;
  73024. private _highligherOpacity;
  73025. private _highlightedText;
  73026. private _startHighlightIndex;
  73027. private _endHighlightIndex;
  73028. private _cursorIndex;
  73029. private _onFocusSelectAll;
  73030. private _isPointerDown;
  73031. private _onClipboardObserver;
  73032. private _onPointerDblTapObserver;
  73033. /** @hidden */
  73034. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73035. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73036. promptMessage: string;
  73037. /** Force disable prompt on mobile device */
  73038. disableMobilePrompt: boolean;
  73039. /** BABYLON.Observable raised when the text changes */
  73040. onTextChangedObservable: BABYLON.Observable<InputText>;
  73041. /** BABYLON.Observable raised just before an entered character is to be added */
  73042. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73043. /** BABYLON.Observable raised when the control gets the focus */
  73044. onFocusObservable: BABYLON.Observable<InputText>;
  73045. /** BABYLON.Observable raised when the control loses the focus */
  73046. onBlurObservable: BABYLON.Observable<InputText>;
  73047. /**Observable raised when the text is highlighted */
  73048. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73049. /**Observable raised when copy event is triggered */
  73050. onTextCopyObservable: BABYLON.Observable<InputText>;
  73051. /** BABYLON.Observable raised when cut event is triggered */
  73052. onTextCutObservable: BABYLON.Observable<InputText>;
  73053. /** BABYLON.Observable raised when paste event is triggered */
  73054. onTextPasteObservable: BABYLON.Observable<InputText>;
  73055. /** BABYLON.Observable raised when a key event was processed */
  73056. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73057. /** Gets or sets the maximum width allowed by the control */
  73058. get maxWidth(): string | number;
  73059. /** Gets the maximum width allowed by the control in pixels */
  73060. get maxWidthInPixels(): number;
  73061. set maxWidth(value: string | number);
  73062. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73063. get highligherOpacity(): number;
  73064. set highligherOpacity(value: number);
  73065. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73066. get onFocusSelectAll(): boolean;
  73067. set onFocusSelectAll(value: boolean);
  73068. /** Gets or sets the text hightlight color */
  73069. get textHighlightColor(): string;
  73070. set textHighlightColor(value: string);
  73071. /** Gets or sets control margin */
  73072. get margin(): string;
  73073. /** Gets control margin in pixels */
  73074. get marginInPixels(): number;
  73075. set margin(value: string);
  73076. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73077. get autoStretchWidth(): boolean;
  73078. set autoStretchWidth(value: boolean);
  73079. /** Gets or sets border thickness */
  73080. get thickness(): number;
  73081. set thickness(value: number);
  73082. /** Gets or sets the background color when focused */
  73083. get focusedBackground(): string;
  73084. set focusedBackground(value: string);
  73085. /** Gets or sets the background color when focused */
  73086. get focusedColor(): string;
  73087. set focusedColor(value: string);
  73088. /** Gets or sets the background color */
  73089. get background(): string;
  73090. set background(value: string);
  73091. /** Gets or sets the placeholder color */
  73092. get placeholderColor(): string;
  73093. set placeholderColor(value: string);
  73094. /** Gets or sets the text displayed when the control is empty */
  73095. get placeholderText(): string;
  73096. set placeholderText(value: string);
  73097. /** Gets or sets the dead key flag */
  73098. get deadKey(): boolean;
  73099. set deadKey(flag: boolean);
  73100. /** Gets or sets the highlight text */
  73101. get highlightedText(): string;
  73102. set highlightedText(text: string);
  73103. /** Gets or sets if the current key should be added */
  73104. get addKey(): boolean;
  73105. set addKey(flag: boolean);
  73106. /** Gets or sets the value of the current key being entered */
  73107. get currentKey(): string;
  73108. set currentKey(key: string);
  73109. /** Gets or sets the text displayed in the control */
  73110. get text(): string;
  73111. set text(value: string);
  73112. /** Gets or sets control width */
  73113. get width(): string | number;
  73114. set width(value: string | number);
  73115. /**
  73116. * Creates a new InputText
  73117. * @param name defines the control name
  73118. * @param text defines the text of the control
  73119. */
  73120. constructor(name?: string | undefined, text?: string);
  73121. /** @hidden */
  73122. onBlur(): void;
  73123. /** @hidden */
  73124. onFocus(): void;
  73125. protected _getTypeName(): string;
  73126. /**
  73127. * Function called to get the list of controls that should not steal the focus from this control
  73128. * @returns an array of controls
  73129. */
  73130. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73131. /** @hidden */
  73132. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73133. /** @hidden */
  73134. private _updateValueFromCursorIndex;
  73135. /** @hidden */
  73136. private _processDblClick;
  73137. /** @hidden */
  73138. private _selectAllText;
  73139. /**
  73140. * Handles the keyboard event
  73141. * @param evt Defines the KeyboardEvent
  73142. */
  73143. processKeyboard(evt: KeyboardEvent): void;
  73144. /** @hidden */
  73145. private _onCopyText;
  73146. /** @hidden */
  73147. private _onCutText;
  73148. /** @hidden */
  73149. private _onPasteText;
  73150. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73151. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73152. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73153. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73154. protected _beforeRenderText(text: string): string;
  73155. dispose(): void;
  73156. }
  73157. }
  73158. declare module BABYLON.GUI {
  73159. /**
  73160. * Class used to create a 2D grid container
  73161. */
  73162. export class Grid extends Container {
  73163. name?: string | undefined;
  73164. private _rowDefinitions;
  73165. private _columnDefinitions;
  73166. private _cells;
  73167. private _childControls;
  73168. /**
  73169. * Gets the number of columns
  73170. */
  73171. get columnCount(): number;
  73172. /**
  73173. * Gets the number of rows
  73174. */
  73175. get rowCount(): number;
  73176. /** Gets the list of children */
  73177. get children(): Control[];
  73178. /** Gets the list of cells (e.g. the containers) */
  73179. get cells(): {
  73180. [key: string]: Container;
  73181. };
  73182. /**
  73183. * Gets the definition of a specific row
  73184. * @param index defines the index of the row
  73185. * @returns the row definition
  73186. */
  73187. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73188. /**
  73189. * Gets the definition of a specific column
  73190. * @param index defines the index of the column
  73191. * @returns the column definition
  73192. */
  73193. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73194. /**
  73195. * Adds a new row to the grid
  73196. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73197. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73198. * @returns the current grid
  73199. */
  73200. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73201. /**
  73202. * Adds a new column to the grid
  73203. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73204. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73205. * @returns the current grid
  73206. */
  73207. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73208. /**
  73209. * Update a row definition
  73210. * @param index defines the index of the row to update
  73211. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73212. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73213. * @returns the current grid
  73214. */
  73215. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73216. /**
  73217. * Update a column definition
  73218. * @param index defines the index of the column to update
  73219. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73220. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73221. * @returns the current grid
  73222. */
  73223. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73224. /**
  73225. * Gets the list of children stored in a specific cell
  73226. * @param row defines the row to check
  73227. * @param column defines the column to check
  73228. * @returns the list of controls
  73229. */
  73230. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73231. /**
  73232. * Gets a string representing the child cell info (row x column)
  73233. * @param child defines the control to get info from
  73234. * @returns a string containing the child cell info (row x column)
  73235. */
  73236. getChildCellInfo(child: Control): string;
  73237. private _removeCell;
  73238. private _offsetCell;
  73239. /**
  73240. * Remove a column definition at specified index
  73241. * @param index defines the index of the column to remove
  73242. * @returns the current grid
  73243. */
  73244. removeColumnDefinition(index: number): Grid;
  73245. /**
  73246. * Remove a row definition at specified index
  73247. * @param index defines the index of the row to remove
  73248. * @returns the current grid
  73249. */
  73250. removeRowDefinition(index: number): Grid;
  73251. /**
  73252. * Adds a new control to the current grid
  73253. * @param control defines the control to add
  73254. * @param row defines the row where to add the control (0 by default)
  73255. * @param column defines the column where to add the control (0 by default)
  73256. * @returns the current grid
  73257. */
  73258. addControl(control: Control, row?: number, column?: number): Grid;
  73259. /**
  73260. * Removes a control from the current container
  73261. * @param control defines the control to remove
  73262. * @returns the current container
  73263. */
  73264. removeControl(control: Control): Container;
  73265. /**
  73266. * Creates a new Grid
  73267. * @param name defines control name
  73268. */
  73269. constructor(name?: string | undefined);
  73270. protected _getTypeName(): string;
  73271. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73272. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73273. _flagDescendantsAsMatrixDirty(): void;
  73274. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73275. /** Releases associated resources */
  73276. dispose(): void;
  73277. }
  73278. }
  73279. declare module BABYLON.GUI {
  73280. /** Class used to create color pickers */
  73281. export class ColorPicker extends Control {
  73282. name?: string | undefined;
  73283. private static _Epsilon;
  73284. private _colorWheelCanvas;
  73285. private _value;
  73286. private _tmpColor;
  73287. private _pointerStartedOnSquare;
  73288. private _pointerStartedOnWheel;
  73289. private _squareLeft;
  73290. private _squareTop;
  73291. private _squareSize;
  73292. private _h;
  73293. private _s;
  73294. private _v;
  73295. private _lastPointerDownID;
  73296. /**
  73297. * BABYLON.Observable raised when the value changes
  73298. */
  73299. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73300. /** Gets or sets the color of the color picker */
  73301. get value(): BABYLON.Color3;
  73302. set value(value: BABYLON.Color3);
  73303. /**
  73304. * Gets or sets control width
  73305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73306. */
  73307. get width(): string | number;
  73308. set width(value: string | number);
  73309. /**
  73310. * Gets or sets control height
  73311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73312. */
  73313. get height(): string | number;
  73314. /** Gets or sets control height */
  73315. set height(value: string | number);
  73316. /** Gets or sets control size */
  73317. get size(): string | number;
  73318. set size(value: string | number);
  73319. /**
  73320. * Creates a new ColorPicker
  73321. * @param name defines the control name
  73322. */
  73323. constructor(name?: string | undefined);
  73324. protected _getTypeName(): string;
  73325. /** @hidden */
  73326. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73327. private _updateSquareProps;
  73328. private _drawGradientSquare;
  73329. private _drawCircle;
  73330. private _createColorWheelCanvas;
  73331. /** @hidden */
  73332. _draw(context: CanvasRenderingContext2D): void;
  73333. private _pointerIsDown;
  73334. private _updateValueFromPointer;
  73335. private _isPointOnSquare;
  73336. private _isPointOnWheel;
  73337. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73338. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73339. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73340. /**
  73341. * This function expands the color picker by creating a color picker dialog with manual
  73342. * color value input and the ability to save colors into an array to be used later in
  73343. * subsequent launches of the dialogue.
  73344. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73345. * @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.
  73346. * @returns picked color as a hex string and the saved colors array as hex strings.
  73347. */
  73348. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73349. pickerWidth?: string;
  73350. pickerHeight?: string;
  73351. headerHeight?: string;
  73352. lastColor?: string;
  73353. swatchLimit?: number;
  73354. numSwatchesPerLine?: number;
  73355. savedColors?: Array<string>;
  73356. }): Promise<{
  73357. savedColors?: string[];
  73358. pickedColor: string;
  73359. }>;
  73360. }
  73361. }
  73362. declare module BABYLON.GUI {
  73363. /** Class used to create 2D ellipse containers */
  73364. export class Ellipse extends Container {
  73365. name?: string | undefined;
  73366. private _thickness;
  73367. /** Gets or sets border thickness */
  73368. get thickness(): number;
  73369. set thickness(value: number);
  73370. /**
  73371. * Creates a new Ellipse
  73372. * @param name defines the control name
  73373. */
  73374. constructor(name?: string | undefined);
  73375. protected _getTypeName(): string;
  73376. protected _localDraw(context: CanvasRenderingContext2D): void;
  73377. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73378. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73379. }
  73380. }
  73381. declare module BABYLON.GUI {
  73382. /**
  73383. * Class used to create a password control
  73384. */
  73385. export class InputPassword extends InputText {
  73386. protected _beforeRenderText(text: string): string;
  73387. }
  73388. }
  73389. declare module BABYLON.GUI {
  73390. /** Class used to render 2D lines */
  73391. export class Line extends Control {
  73392. name?: string | undefined;
  73393. private _lineWidth;
  73394. private _x1;
  73395. private _y1;
  73396. private _x2;
  73397. private _y2;
  73398. private _dash;
  73399. private _connectedControl;
  73400. private _connectedControlDirtyObserver;
  73401. /** Gets or sets the dash pattern */
  73402. get dash(): Array<number>;
  73403. set dash(value: Array<number>);
  73404. /** Gets or sets the control connected with the line end */
  73405. get connectedControl(): Control;
  73406. set connectedControl(value: Control);
  73407. /** Gets or sets start coordinates on X axis */
  73408. get x1(): string | number;
  73409. set x1(value: string | number);
  73410. /** Gets or sets start coordinates on Y axis */
  73411. get y1(): string | number;
  73412. set y1(value: string | number);
  73413. /** Gets or sets end coordinates on X axis */
  73414. get x2(): string | number;
  73415. set x2(value: string | number);
  73416. /** Gets or sets end coordinates on Y axis */
  73417. get y2(): string | number;
  73418. set y2(value: string | number);
  73419. /** Gets or sets line width */
  73420. get lineWidth(): number;
  73421. set lineWidth(value: number);
  73422. /** Gets or sets horizontal alignment */
  73423. set horizontalAlignment(value: number);
  73424. /** Gets or sets vertical alignment */
  73425. set verticalAlignment(value: number);
  73426. private get _effectiveX2();
  73427. private get _effectiveY2();
  73428. /**
  73429. * Creates a new Line
  73430. * @param name defines the control name
  73431. */
  73432. constructor(name?: string | undefined);
  73433. protected _getTypeName(): string;
  73434. _draw(context: CanvasRenderingContext2D): void;
  73435. _measure(): void;
  73436. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73437. /**
  73438. * Move one end of the line given 3D cartesian coordinates.
  73439. * @param position Targeted world position
  73440. * @param scene BABYLON.Scene
  73441. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73442. */
  73443. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73444. /**
  73445. * Move one end of the line to a position in screen absolute space.
  73446. * @param projectedPosition Position in screen absolute space (X, Y)
  73447. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73448. */
  73449. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73450. }
  73451. }
  73452. declare module BABYLON.GUI {
  73453. /**
  73454. * Class used to store a point for a MultiLine object.
  73455. * The point can be pure 2D coordinates, a mesh or a control
  73456. */
  73457. export class MultiLinePoint {
  73458. private _multiLine;
  73459. private _x;
  73460. private _y;
  73461. private _control;
  73462. private _mesh;
  73463. private _controlObserver;
  73464. private _meshObserver;
  73465. /** @hidden */
  73466. _point: BABYLON.Vector2;
  73467. /**
  73468. * Creates a new MultiLinePoint
  73469. * @param multiLine defines the source MultiLine object
  73470. */
  73471. constructor(multiLine: MultiLine);
  73472. /** Gets or sets x coordinate */
  73473. get x(): string | number;
  73474. set x(value: string | number);
  73475. /** Gets or sets y coordinate */
  73476. get y(): string | number;
  73477. set y(value: string | number);
  73478. /** Gets or sets the control associated with this point */
  73479. get control(): BABYLON.Nullable<Control>;
  73480. set control(value: BABYLON.Nullable<Control>);
  73481. /** Gets or sets the mesh associated with this point */
  73482. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73483. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73484. /** Resets links */
  73485. resetLinks(): void;
  73486. /**
  73487. * Gets a translation vector
  73488. * @returns the translation vector
  73489. */
  73490. translate(): BABYLON.Vector2;
  73491. private _translatePoint;
  73492. /** Release associated resources */
  73493. dispose(): void;
  73494. }
  73495. }
  73496. declare module BABYLON.GUI {
  73497. /**
  73498. * Class used to create multi line control
  73499. */
  73500. export class MultiLine extends Control {
  73501. name?: string | undefined;
  73502. private _lineWidth;
  73503. private _dash;
  73504. private _points;
  73505. private _minX;
  73506. private _minY;
  73507. private _maxX;
  73508. private _maxY;
  73509. /**
  73510. * Creates a new MultiLine
  73511. * @param name defines the control name
  73512. */
  73513. constructor(name?: string | undefined);
  73514. /** Gets or sets dash pattern */
  73515. get dash(): Array<number>;
  73516. set dash(value: Array<number>);
  73517. /**
  73518. * Gets point stored at specified index
  73519. * @param index defines the index to look for
  73520. * @returns the requested point if found
  73521. */
  73522. getAt(index: number): MultiLinePoint;
  73523. /** Function called when a point is updated */
  73524. onPointUpdate: () => void;
  73525. /**
  73526. * Adds new points to the point collection
  73527. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73528. * @returns the list of created MultiLinePoint
  73529. */
  73530. add(...items: (AbstractMesh | Control | {
  73531. x: string | number;
  73532. y: string | number;
  73533. })[]): MultiLinePoint[];
  73534. /**
  73535. * Adds a new point to the point collection
  73536. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73537. * @returns the created MultiLinePoint
  73538. */
  73539. push(item?: (AbstractMesh | Control | {
  73540. x: string | number;
  73541. y: string | number;
  73542. })): MultiLinePoint;
  73543. /**
  73544. * Remove a specific value or point from the active point collection
  73545. * @param value defines the value or point to remove
  73546. */
  73547. remove(value: number | MultiLinePoint): void;
  73548. /**
  73549. * Resets this object to initial state (no point)
  73550. */
  73551. reset(): void;
  73552. /**
  73553. * Resets all links
  73554. */
  73555. resetLinks(): void;
  73556. /** Gets or sets line width */
  73557. get lineWidth(): number;
  73558. set lineWidth(value: number);
  73559. set horizontalAlignment(value: number);
  73560. set verticalAlignment(value: number);
  73561. protected _getTypeName(): string;
  73562. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73563. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73564. _measure(): void;
  73565. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73566. dispose(): void;
  73567. }
  73568. }
  73569. declare module BABYLON.GUI {
  73570. /**
  73571. * Class used to create radio button controls
  73572. */
  73573. export class RadioButton extends Control {
  73574. name?: string | undefined;
  73575. private _isChecked;
  73576. private _background;
  73577. private _checkSizeRatio;
  73578. private _thickness;
  73579. /** Gets or sets border thickness */
  73580. get thickness(): number;
  73581. set thickness(value: number);
  73582. /** Gets or sets group name */
  73583. group: string;
  73584. /** BABYLON.Observable raised when isChecked is changed */
  73585. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73586. /** Gets or sets a value indicating the ratio between overall size and check size */
  73587. get checkSizeRatio(): number;
  73588. set checkSizeRatio(value: number);
  73589. /** Gets or sets background color */
  73590. get background(): string;
  73591. set background(value: string);
  73592. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73593. get isChecked(): boolean;
  73594. set isChecked(value: boolean);
  73595. /**
  73596. * Creates a new RadioButton
  73597. * @param name defines the control name
  73598. */
  73599. constructor(name?: string | undefined);
  73600. protected _getTypeName(): string;
  73601. _draw(context: CanvasRenderingContext2D): void;
  73602. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73603. /**
  73604. * Utility function to easily create a radio button with a header
  73605. * @param title defines the label to use for the header
  73606. * @param group defines the group to use for the radio button
  73607. * @param isChecked defines the initial state of the radio button
  73608. * @param onValueChanged defines the callback to call when value changes
  73609. * @returns a StackPanel containing the radio button and a textBlock
  73610. */
  73611. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73612. }
  73613. }
  73614. declare module BABYLON.GUI {
  73615. /**
  73616. * Class used to create slider controls
  73617. */
  73618. export class BaseSlider extends Control {
  73619. name?: string | undefined;
  73620. protected _thumbWidth: ValueAndUnit;
  73621. private _minimum;
  73622. private _maximum;
  73623. private _value;
  73624. private _isVertical;
  73625. protected _barOffset: ValueAndUnit;
  73626. private _isThumbClamped;
  73627. protected _displayThumb: boolean;
  73628. private _step;
  73629. private _lastPointerDownID;
  73630. protected _effectiveBarOffset: number;
  73631. protected _renderLeft: number;
  73632. protected _renderTop: number;
  73633. protected _renderWidth: number;
  73634. protected _renderHeight: number;
  73635. protected _backgroundBoxLength: number;
  73636. protected _backgroundBoxThickness: number;
  73637. protected _effectiveThumbThickness: number;
  73638. /** BABYLON.Observable raised when the sldier value changes */
  73639. onValueChangedObservable: BABYLON.Observable<number>;
  73640. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73641. get displayThumb(): boolean;
  73642. set displayThumb(value: boolean);
  73643. /** Gets or sets a step to apply to values (0 by default) */
  73644. get step(): number;
  73645. set step(value: number);
  73646. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73647. get barOffset(): string | number;
  73648. /** Gets main bar offset in pixels*/
  73649. get barOffsetInPixels(): number;
  73650. set barOffset(value: string | number);
  73651. /** Gets or sets thumb width */
  73652. get thumbWidth(): string | number;
  73653. /** Gets thumb width in pixels */
  73654. get thumbWidthInPixels(): number;
  73655. set thumbWidth(value: string | number);
  73656. /** Gets or sets minimum value */
  73657. get minimum(): number;
  73658. set minimum(value: number);
  73659. /** Gets or sets maximum value */
  73660. get maximum(): number;
  73661. set maximum(value: number);
  73662. /** Gets or sets current value */
  73663. get value(): number;
  73664. set value(value: number);
  73665. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73666. get isVertical(): boolean;
  73667. set isVertical(value: boolean);
  73668. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73669. get isThumbClamped(): boolean;
  73670. set isThumbClamped(value: boolean);
  73671. /**
  73672. * Creates a new BaseSlider
  73673. * @param name defines the control name
  73674. */
  73675. constructor(name?: string | undefined);
  73676. protected _getTypeName(): string;
  73677. protected _getThumbPosition(): number;
  73678. protected _getThumbThickness(type: string): number;
  73679. protected _prepareRenderingData(type: string): void;
  73680. private _pointerIsDown;
  73681. /** @hidden */
  73682. protected _updateValueFromPointer(x: number, y: number): void;
  73683. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73684. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73685. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73686. }
  73687. }
  73688. declare module BABYLON.GUI {
  73689. /**
  73690. * Class used to create slider controls
  73691. */
  73692. export class Slider extends BaseSlider {
  73693. name?: string | undefined;
  73694. private _background;
  73695. private _borderColor;
  73696. private _isThumbCircle;
  73697. protected _displayValueBar: boolean;
  73698. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73699. get displayValueBar(): boolean;
  73700. set displayValueBar(value: boolean);
  73701. /** Gets or sets border color */
  73702. get borderColor(): string;
  73703. set borderColor(value: string);
  73704. /** Gets or sets background color */
  73705. get background(): string;
  73706. set background(value: string);
  73707. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73708. get isThumbCircle(): boolean;
  73709. set isThumbCircle(value: boolean);
  73710. /**
  73711. * Creates a new Slider
  73712. * @param name defines the control name
  73713. */
  73714. constructor(name?: string | undefined);
  73715. protected _getTypeName(): string;
  73716. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73717. }
  73718. }
  73719. declare module BABYLON.GUI {
  73720. /** Class used to create a RadioGroup
  73721. * which contains groups of radio buttons
  73722. */
  73723. export class SelectorGroup {
  73724. /** name of SelectorGroup */
  73725. name: string;
  73726. private _groupPanel;
  73727. private _selectors;
  73728. private _groupHeader;
  73729. /**
  73730. * Creates a new SelectorGroup
  73731. * @param name of group, used as a group heading
  73732. */
  73733. constructor(
  73734. /** name of SelectorGroup */
  73735. name: string);
  73736. /** Gets the groupPanel of the SelectorGroup */
  73737. get groupPanel(): StackPanel;
  73738. /** Gets the selectors array */
  73739. get selectors(): StackPanel[];
  73740. /** Gets and sets the group header */
  73741. get header(): string;
  73742. set header(label: string);
  73743. /** @hidden */
  73744. private _addGroupHeader;
  73745. /** @hidden*/
  73746. _getSelector(selectorNb: number): StackPanel | undefined;
  73747. /** Removes the selector at the given position
  73748. * @param selectorNb the position of the selector within the group
  73749. */
  73750. removeSelector(selectorNb: number): void;
  73751. }
  73752. /** Class used to create a CheckboxGroup
  73753. * which contains groups of checkbox buttons
  73754. */
  73755. export class CheckboxGroup extends SelectorGroup {
  73756. /** Adds a checkbox as a control
  73757. * @param text is the label for the selector
  73758. * @param func is the function called when the Selector is checked
  73759. * @param checked is true when Selector is checked
  73760. */
  73761. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73762. /** @hidden */
  73763. _setSelectorLabel(selectorNb: number, label: string): void;
  73764. /** @hidden */
  73765. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73766. /** @hidden */
  73767. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73768. /** @hidden */
  73769. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73770. }
  73771. /** Class used to create a RadioGroup
  73772. * which contains groups of radio buttons
  73773. */
  73774. export class RadioGroup extends SelectorGroup {
  73775. private _selectNb;
  73776. /** Adds a radio button as a control
  73777. * @param label is the label for the selector
  73778. * @param func is the function called when the Selector is checked
  73779. * @param checked is true when Selector is checked
  73780. */
  73781. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73782. /** @hidden */
  73783. _setSelectorLabel(selectorNb: number, label: string): void;
  73784. /** @hidden */
  73785. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73786. /** @hidden */
  73787. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73788. /** @hidden */
  73789. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73790. }
  73791. /** Class used to create a SliderGroup
  73792. * which contains groups of slider buttons
  73793. */
  73794. export class SliderGroup extends SelectorGroup {
  73795. /**
  73796. * Adds a slider to the SelectorGroup
  73797. * @param label is the label for the SliderBar
  73798. * @param func is the function called when the Slider moves
  73799. * @param unit is a string describing the units used, eg degrees or metres
  73800. * @param min is the minimum value for the Slider
  73801. * @param max is the maximum value for the Slider
  73802. * @param value is the start value for the Slider between min and max
  73803. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73804. */
  73805. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73806. /** @hidden */
  73807. _setSelectorLabel(selectorNb: number, label: string): void;
  73808. /** @hidden */
  73809. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73810. /** @hidden */
  73811. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73812. /** @hidden */
  73813. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73814. }
  73815. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73816. * @see http://doc.babylonjs.com/how_to/selector
  73817. */
  73818. export class SelectionPanel extends Rectangle {
  73819. /** name of SelectionPanel */
  73820. name: string;
  73821. /** an array of SelectionGroups */
  73822. groups: SelectorGroup[];
  73823. private _panel;
  73824. private _buttonColor;
  73825. private _buttonBackground;
  73826. private _headerColor;
  73827. private _barColor;
  73828. private _barHeight;
  73829. private _spacerHeight;
  73830. private _labelColor;
  73831. private _groups;
  73832. private _bars;
  73833. /**
  73834. * Creates a new SelectionPanel
  73835. * @param name of SelectionPanel
  73836. * @param groups is an array of SelectionGroups
  73837. */
  73838. constructor(
  73839. /** name of SelectionPanel */
  73840. name: string,
  73841. /** an array of SelectionGroups */
  73842. groups?: SelectorGroup[]);
  73843. protected _getTypeName(): string;
  73844. /** Gets or sets the headerColor */
  73845. get headerColor(): string;
  73846. set headerColor(color: string);
  73847. private _setHeaderColor;
  73848. /** Gets or sets the button color */
  73849. get buttonColor(): string;
  73850. set buttonColor(color: string);
  73851. private _setbuttonColor;
  73852. /** Gets or sets the label color */
  73853. get labelColor(): string;
  73854. set labelColor(color: string);
  73855. private _setLabelColor;
  73856. /** Gets or sets the button background */
  73857. get buttonBackground(): string;
  73858. set buttonBackground(color: string);
  73859. private _setButtonBackground;
  73860. /** Gets or sets the color of separator bar */
  73861. get barColor(): string;
  73862. set barColor(color: string);
  73863. private _setBarColor;
  73864. /** Gets or sets the height of separator bar */
  73865. get barHeight(): string;
  73866. set barHeight(value: string);
  73867. private _setBarHeight;
  73868. /** Gets or sets the height of spacers*/
  73869. get spacerHeight(): string;
  73870. set spacerHeight(value: string);
  73871. private _setSpacerHeight;
  73872. /** Adds a bar between groups */
  73873. private _addSpacer;
  73874. /** Add a group to the selection panel
  73875. * @param group is the selector group to add
  73876. */
  73877. addGroup(group: SelectorGroup): void;
  73878. /** Remove the group from the given position
  73879. * @param groupNb is the position of the group in the list
  73880. */
  73881. removeGroup(groupNb: number): void;
  73882. /** Change a group header label
  73883. * @param label is the new group header label
  73884. * @param groupNb is the number of the group to relabel
  73885. * */
  73886. setHeaderName(label: string, groupNb: number): void;
  73887. /** Change selector label to the one given
  73888. * @param label is the new selector label
  73889. * @param groupNb is the number of the groupcontaining the selector
  73890. * @param selectorNb is the number of the selector within a group to relabel
  73891. * */
  73892. relabel(label: string, groupNb: number, selectorNb: number): void;
  73893. /** For a given group position remove the selector at the given position
  73894. * @param groupNb is the number of the group to remove the selector from
  73895. * @param selectorNb is the number of the selector within the group
  73896. */
  73897. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73898. /** For a given group position of correct type add a checkbox button
  73899. * @param groupNb is the number of the group to remove the selector from
  73900. * @param label is the label for the selector
  73901. * @param func is the function called when the Selector is checked
  73902. * @param checked is true when Selector is checked
  73903. */
  73904. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73905. /** For a given group position of correct type add a radio button
  73906. * @param groupNb is the number of the group to remove the selector from
  73907. * @param label is the label for the selector
  73908. * @param func is the function called when the Selector is checked
  73909. * @param checked is true when Selector is checked
  73910. */
  73911. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73912. /**
  73913. * For a given slider group add a slider
  73914. * @param groupNb is the number of the group to add the slider to
  73915. * @param label is the label for the Slider
  73916. * @param func is the function called when the Slider moves
  73917. * @param unit is a string describing the units used, eg degrees or metres
  73918. * @param min is the minimum value for the Slider
  73919. * @param max is the maximum value for the Slider
  73920. * @param value is the start value for the Slider between min and max
  73921. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73922. */
  73923. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73924. }
  73925. }
  73926. declare module BABYLON.GUI {
  73927. /**
  73928. * Class used to hold a the container for ScrollViewer
  73929. * @hidden
  73930. */
  73931. export class _ScrollViewerWindow extends Container {
  73932. parentClientWidth: number;
  73933. parentClientHeight: number;
  73934. private _freezeControls;
  73935. private _parentMeasure;
  73936. private _oldLeft;
  73937. private _oldTop;
  73938. get freezeControls(): boolean;
  73939. set freezeControls(value: boolean);
  73940. private _bucketWidth;
  73941. private _bucketHeight;
  73942. private _buckets;
  73943. private _bucketLen;
  73944. get bucketWidth(): number;
  73945. get bucketHeight(): number;
  73946. setBucketSizes(width: number, height: number): void;
  73947. private _useBuckets;
  73948. private _makeBuckets;
  73949. private _dispatchInBuckets;
  73950. private _updateMeasures;
  73951. private _updateChildrenMeasures;
  73952. private _restoreMeasures;
  73953. /**
  73954. * Creates a new ScrollViewerWindow
  73955. * @param name of ScrollViewerWindow
  73956. */
  73957. constructor(name?: string);
  73958. protected _getTypeName(): string;
  73959. /** @hidden */
  73960. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73961. /** @hidden */
  73962. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73963. private _scrollChildren;
  73964. private _scrollChildrenWithBuckets;
  73965. /** @hidden */
  73966. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73967. protected _postMeasure(): void;
  73968. }
  73969. }
  73970. declare module BABYLON.GUI {
  73971. /**
  73972. * Class used to create slider controls
  73973. */
  73974. export class ScrollBar extends BaseSlider {
  73975. name?: string | undefined;
  73976. private _background;
  73977. private _borderColor;
  73978. private _tempMeasure;
  73979. /** Gets or sets border color */
  73980. get borderColor(): string;
  73981. set borderColor(value: string);
  73982. /** Gets or sets background color */
  73983. get background(): string;
  73984. set background(value: string);
  73985. /**
  73986. * Creates a new Slider
  73987. * @param name defines the control name
  73988. */
  73989. constructor(name?: string | undefined);
  73990. protected _getTypeName(): string;
  73991. protected _getThumbThickness(): number;
  73992. _draw(context: CanvasRenderingContext2D): void;
  73993. private _first;
  73994. private _originX;
  73995. private _originY;
  73996. /** @hidden */
  73997. protected _updateValueFromPointer(x: number, y: number): void;
  73998. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73999. }
  74000. }
  74001. declare module BABYLON.GUI {
  74002. /**
  74003. * Class used to create slider controls
  74004. */
  74005. export class ImageScrollBar extends BaseSlider {
  74006. name?: string | undefined;
  74007. private _backgroundBaseImage;
  74008. private _backgroundImage;
  74009. private _thumbImage;
  74010. private _thumbBaseImage;
  74011. private _thumbLength;
  74012. private _thumbHeight;
  74013. private _barImageHeight;
  74014. private _tempMeasure;
  74015. /** Number of 90° rotation to apply on the images when in vertical mode */
  74016. num90RotationInVerticalMode: number;
  74017. /**
  74018. * Gets or sets the image used to render the background for horizontal bar
  74019. */
  74020. get backgroundImage(): Image;
  74021. set backgroundImage(value: Image);
  74022. /**
  74023. * Gets or sets the image used to render the thumb
  74024. */
  74025. get thumbImage(): Image;
  74026. set thumbImage(value: Image);
  74027. /**
  74028. * Gets or sets the length of the thumb
  74029. */
  74030. get thumbLength(): number;
  74031. set thumbLength(value: number);
  74032. /**
  74033. * Gets or sets the height of the thumb
  74034. */
  74035. get thumbHeight(): number;
  74036. set thumbHeight(value: number);
  74037. /**
  74038. * Gets or sets the height of the bar image
  74039. */
  74040. get barImageHeight(): number;
  74041. set barImageHeight(value: number);
  74042. /**
  74043. * Creates a new ImageScrollBar
  74044. * @param name defines the control name
  74045. */
  74046. constructor(name?: string | undefined);
  74047. protected _getTypeName(): string;
  74048. protected _getThumbThickness(): number;
  74049. _draw(context: CanvasRenderingContext2D): void;
  74050. private _first;
  74051. private _originX;
  74052. private _originY;
  74053. /** @hidden */
  74054. protected _updateValueFromPointer(x: number, y: number): void;
  74055. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74056. }
  74057. }
  74058. declare module BABYLON.GUI {
  74059. /**
  74060. * Class used to hold a viewer window and sliders in a grid
  74061. */
  74062. export class ScrollViewer extends Rectangle {
  74063. private _grid;
  74064. private _horizontalBarSpace;
  74065. private _verticalBarSpace;
  74066. private _dragSpace;
  74067. private _horizontalBar;
  74068. private _verticalBar;
  74069. private _barColor;
  74070. private _barBackground;
  74071. private _barImage;
  74072. private _horizontalBarImage;
  74073. private _verticalBarImage;
  74074. private _barBackgroundImage;
  74075. private _horizontalBarBackgroundImage;
  74076. private _verticalBarBackgroundImage;
  74077. private _barSize;
  74078. private _window;
  74079. private _pointerIsOver;
  74080. private _wheelPrecision;
  74081. private _onWheelObserver;
  74082. private _clientWidth;
  74083. private _clientHeight;
  74084. private _useImageBar;
  74085. private _thumbLength;
  74086. private _thumbHeight;
  74087. private _barImageHeight;
  74088. private _horizontalBarImageHeight;
  74089. private _verticalBarImageHeight;
  74090. private _oldWindowContentsWidth;
  74091. private _oldWindowContentsHeight;
  74092. /**
  74093. * Gets the horizontal scrollbar
  74094. */
  74095. get horizontalBar(): ScrollBar | ImageScrollBar;
  74096. /**
  74097. * Gets the vertical scrollbar
  74098. */
  74099. get verticalBar(): ScrollBar | ImageScrollBar;
  74100. /**
  74101. * Adds a new control to the current container
  74102. * @param control defines the control to add
  74103. * @returns the current container
  74104. */
  74105. addControl(control: BABYLON.Nullable<Control>): Container;
  74106. /**
  74107. * Removes a control from the current container
  74108. * @param control defines the control to remove
  74109. * @returns the current container
  74110. */
  74111. removeControl(control: Control): Container;
  74112. /** Gets the list of children */
  74113. get children(): Control[];
  74114. _flagDescendantsAsMatrixDirty(): void;
  74115. /**
  74116. * Freezes or unfreezes the controls in the window.
  74117. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74118. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74119. */
  74120. get freezeControls(): boolean;
  74121. set freezeControls(value: boolean);
  74122. /** Gets the bucket width */
  74123. get bucketWidth(): number;
  74124. /** Gets the bucket height */
  74125. get bucketHeight(): number;
  74126. /**
  74127. * Sets the bucket sizes.
  74128. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74129. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74130. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74131. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74132. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74133. * used), that's why it is not enabled by default.
  74134. * @param width width of the bucket
  74135. * @param height height of the bucket
  74136. */
  74137. setBucketSizes(width: number, height: number): void;
  74138. private _forceHorizontalBar;
  74139. private _forceVerticalBar;
  74140. /**
  74141. * Forces the horizontal scroll bar to be displayed
  74142. */
  74143. get forceHorizontalBar(): boolean;
  74144. set forceHorizontalBar(value: boolean);
  74145. /**
  74146. * Forces the vertical scroll bar to be displayed
  74147. */
  74148. get forceVerticalBar(): boolean;
  74149. set forceVerticalBar(value: boolean);
  74150. /**
  74151. * Creates a new ScrollViewer
  74152. * @param name of ScrollViewer
  74153. */
  74154. constructor(name?: string, isImageBased?: boolean);
  74155. /** Reset the scroll viewer window to initial size */
  74156. resetWindow(): void;
  74157. protected _getTypeName(): string;
  74158. private _buildClientSizes;
  74159. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74160. protected _postMeasure(): void;
  74161. /**
  74162. * Gets or sets the mouse wheel precision
  74163. * from 0 to 1 with a default value of 0.05
  74164. * */
  74165. get wheelPrecision(): number;
  74166. set wheelPrecision(value: number);
  74167. /** Gets or sets the scroll bar container background color */
  74168. get scrollBackground(): string;
  74169. set scrollBackground(color: string);
  74170. /** Gets or sets the bar color */
  74171. get barColor(): string;
  74172. set barColor(color: string);
  74173. /** Gets or sets the bar image */
  74174. get thumbImage(): Image;
  74175. set thumbImage(value: Image);
  74176. /** Gets or sets the horizontal bar image */
  74177. get horizontalThumbImage(): Image;
  74178. set horizontalThumbImage(value: Image);
  74179. /** Gets or sets the vertical bar image */
  74180. get verticalThumbImage(): Image;
  74181. set verticalThumbImage(value: Image);
  74182. /** Gets or sets the size of the bar */
  74183. get barSize(): number;
  74184. set barSize(value: number);
  74185. /** Gets or sets the length of the thumb */
  74186. get thumbLength(): number;
  74187. set thumbLength(value: number);
  74188. /** Gets or sets the height of the thumb */
  74189. get thumbHeight(): number;
  74190. set thumbHeight(value: number);
  74191. /** Gets or sets the height of the bar image */
  74192. get barImageHeight(): number;
  74193. set barImageHeight(value: number);
  74194. /** Gets or sets the height of the horizontal bar image */
  74195. get horizontalBarImageHeight(): number;
  74196. set horizontalBarImageHeight(value: number);
  74197. /** Gets or sets the height of the vertical bar image */
  74198. get verticalBarImageHeight(): number;
  74199. set verticalBarImageHeight(value: number);
  74200. /** Gets or sets the bar background */
  74201. get barBackground(): string;
  74202. set barBackground(color: string);
  74203. /** Gets or sets the bar background image */
  74204. get barImage(): Image;
  74205. set barImage(value: Image);
  74206. /** Gets or sets the horizontal bar background image */
  74207. get horizontalBarImage(): Image;
  74208. set horizontalBarImage(value: Image);
  74209. /** Gets or sets the vertical bar background image */
  74210. get verticalBarImage(): Image;
  74211. set verticalBarImage(value: Image);
  74212. private _setWindowPosition;
  74213. /** @hidden */
  74214. private _updateScroller;
  74215. _link(host: AdvancedDynamicTexture): void;
  74216. /** @hidden */
  74217. private _addBar;
  74218. /** @hidden */
  74219. private _attachWheel;
  74220. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74221. /** Releases associated resources */
  74222. dispose(): void;
  74223. }
  74224. }
  74225. declare module BABYLON.GUI {
  74226. /** Class used to render a grid */
  74227. export class DisplayGrid extends Control {
  74228. name?: string | undefined;
  74229. private _cellWidth;
  74230. private _cellHeight;
  74231. private _minorLineTickness;
  74232. private _minorLineColor;
  74233. private _majorLineTickness;
  74234. private _majorLineColor;
  74235. private _majorLineFrequency;
  74236. private _background;
  74237. private _displayMajorLines;
  74238. private _displayMinorLines;
  74239. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74240. get displayMinorLines(): boolean;
  74241. set displayMinorLines(value: boolean);
  74242. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74243. get displayMajorLines(): boolean;
  74244. set displayMajorLines(value: boolean);
  74245. /** Gets or sets background color (Black by default) */
  74246. get background(): string;
  74247. set background(value: string);
  74248. /** Gets or sets the width of each cell (20 by default) */
  74249. get cellWidth(): number;
  74250. set cellWidth(value: number);
  74251. /** Gets or sets the height of each cell (20 by default) */
  74252. get cellHeight(): number;
  74253. set cellHeight(value: number);
  74254. /** Gets or sets the tickness of minor lines (1 by default) */
  74255. get minorLineTickness(): number;
  74256. set minorLineTickness(value: number);
  74257. /** Gets or sets the color of minor lines (DarkGray by default) */
  74258. get minorLineColor(): string;
  74259. set minorLineColor(value: string);
  74260. /** Gets or sets the tickness of major lines (2 by default) */
  74261. get majorLineTickness(): number;
  74262. set majorLineTickness(value: number);
  74263. /** Gets or sets the color of major lines (White by default) */
  74264. get majorLineColor(): string;
  74265. set majorLineColor(value: string);
  74266. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74267. get majorLineFrequency(): number;
  74268. set majorLineFrequency(value: number);
  74269. /**
  74270. * Creates a new GridDisplayRectangle
  74271. * @param name defines the control name
  74272. */
  74273. constructor(name?: string | undefined);
  74274. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74275. protected _getTypeName(): string;
  74276. }
  74277. }
  74278. declare module BABYLON.GUI {
  74279. /**
  74280. * Class used to create slider controls based on images
  74281. */
  74282. export class ImageBasedSlider extends BaseSlider {
  74283. name?: string | undefined;
  74284. private _backgroundImage;
  74285. private _thumbImage;
  74286. private _valueBarImage;
  74287. private _tempMeasure;
  74288. get displayThumb(): boolean;
  74289. set displayThumb(value: boolean);
  74290. /**
  74291. * Gets or sets the image used to render the background
  74292. */
  74293. get backgroundImage(): Image;
  74294. set backgroundImage(value: Image);
  74295. /**
  74296. * Gets or sets the image used to render the value bar
  74297. */
  74298. get valueBarImage(): Image;
  74299. set valueBarImage(value: Image);
  74300. /**
  74301. * Gets or sets the image used to render the thumb
  74302. */
  74303. get thumbImage(): Image;
  74304. set thumbImage(value: Image);
  74305. /**
  74306. * Creates a new ImageBasedSlider
  74307. * @param name defines the control name
  74308. */
  74309. constructor(name?: string | undefined);
  74310. protected _getTypeName(): string;
  74311. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74312. }
  74313. }
  74314. declare module BABYLON.GUI {
  74315. /**
  74316. * Forcing an export so that this code will execute
  74317. * @hidden
  74318. */
  74319. const name = "Statics";
  74320. }
  74321. declare module BABYLON.GUI {
  74322. /**
  74323. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74324. */
  74325. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74326. /**
  74327. * Define the instrumented AdvancedDynamicTexture.
  74328. */
  74329. texture: AdvancedDynamicTexture;
  74330. private _captureRenderTime;
  74331. private _renderTime;
  74332. private _captureLayoutTime;
  74333. private _layoutTime;
  74334. private _onBeginRenderObserver;
  74335. private _onEndRenderObserver;
  74336. private _onBeginLayoutObserver;
  74337. private _onEndLayoutObserver;
  74338. /**
  74339. * Gets the perf counter used to capture render time
  74340. */
  74341. get renderTimeCounter(): BABYLON.PerfCounter;
  74342. /**
  74343. * Gets the perf counter used to capture layout time
  74344. */
  74345. get layoutTimeCounter(): BABYLON.PerfCounter;
  74346. /**
  74347. * Enable or disable the render time capture
  74348. */
  74349. get captureRenderTime(): boolean;
  74350. set captureRenderTime(value: boolean);
  74351. /**
  74352. * Enable or disable the layout time capture
  74353. */
  74354. get captureLayoutTime(): boolean;
  74355. set captureLayoutTime(value: boolean);
  74356. /**
  74357. * Instantiates a new advanced dynamic texture instrumentation.
  74358. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74359. * @param texture Defines the AdvancedDynamicTexture to instrument
  74360. */
  74361. constructor(
  74362. /**
  74363. * Define the instrumented AdvancedDynamicTexture.
  74364. */
  74365. texture: AdvancedDynamicTexture);
  74366. /**
  74367. * Dispose and release associated resources.
  74368. */
  74369. dispose(): void;
  74370. }
  74371. }
  74372. declare module BABYLON.GUI {
  74373. /**
  74374. * Class used to load GUI via XML.
  74375. */
  74376. export class XmlLoader {
  74377. private _nodes;
  74378. private _nodeTypes;
  74379. private _isLoaded;
  74380. private _objectAttributes;
  74381. private _parentClass;
  74382. /**
  74383. * Create a new xml loader
  74384. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74385. */
  74386. constructor(parentClass?: null);
  74387. private _getChainElement;
  74388. private _getClassAttribute;
  74389. private _createGuiElement;
  74390. private _parseGrid;
  74391. private _parseElement;
  74392. private _prepareSourceElement;
  74393. private _parseElementsFromSource;
  74394. private _parseXml;
  74395. /**
  74396. * Gets if the loading has finished.
  74397. * @returns whether the loading has finished or not
  74398. */
  74399. isLoaded(): boolean;
  74400. /**
  74401. * Gets a loaded node / control by id.
  74402. * @param id the Controls id set in the xml
  74403. * @returns element of type Control
  74404. */
  74405. getNodeById(id: string): any;
  74406. /**
  74407. * Gets all loaded nodes / controls
  74408. * @returns Array of controls
  74409. */
  74410. getNodes(): any;
  74411. /**
  74412. * Initiates the xml layout loading
  74413. * @param xmlFile defines the xml layout to load
  74414. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74415. * @param callback defines the callback called on layout load.
  74416. */
  74417. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74418. }
  74419. }
  74420. declare module BABYLON.GUI {
  74421. /**
  74422. * Class used to create containers for controls
  74423. */
  74424. export class Container3D extends Control3D {
  74425. private _blockLayout;
  74426. /**
  74427. * Gets the list of child controls
  74428. */
  74429. protected _children: Control3D[];
  74430. /**
  74431. * Gets the list of child controls
  74432. */
  74433. get children(): Array<Control3D>;
  74434. /**
  74435. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74436. * This is helpful to optimize layout operation when adding multiple children in a row
  74437. */
  74438. get blockLayout(): boolean;
  74439. set blockLayout(value: boolean);
  74440. /**
  74441. * Creates a new container
  74442. * @param name defines the container name
  74443. */
  74444. constructor(name?: string);
  74445. /**
  74446. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74447. * @returns the current container
  74448. */
  74449. updateLayout(): Container3D;
  74450. /**
  74451. * Gets a boolean indicating if the given control is in the children of this control
  74452. * @param control defines the control to check
  74453. * @returns true if the control is in the child list
  74454. */
  74455. containsControl(control: Control3D): boolean;
  74456. /**
  74457. * Adds a control to the children of this control
  74458. * @param control defines the control to add
  74459. * @returns the current container
  74460. */
  74461. addControl(control: Control3D): Container3D;
  74462. /**
  74463. * This function will be called everytime a new control is added
  74464. */
  74465. protected _arrangeChildren(): void;
  74466. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74467. /**
  74468. * Removes a control from the children of this control
  74469. * @param control defines the control to remove
  74470. * @returns the current container
  74471. */
  74472. removeControl(control: Control3D): Container3D;
  74473. protected _getTypeName(): string;
  74474. /**
  74475. * Releases all associated resources
  74476. */
  74477. dispose(): void;
  74478. /** Control rotation will remain unchanged */
  74479. static readonly UNSET_ORIENTATION: number;
  74480. /** Control will rotate to make it look at sphere central axis */
  74481. static readonly FACEORIGIN_ORIENTATION: number;
  74482. /** Control will rotate to make it look back at sphere central axis */
  74483. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74484. /** Control will rotate to look at z axis (0, 0, 1) */
  74485. static readonly FACEFORWARD_ORIENTATION: number;
  74486. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74487. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74488. }
  74489. }
  74490. declare module BABYLON.GUI {
  74491. /**
  74492. * Class used to manage 3D user interface
  74493. * @see http://doc.babylonjs.com/how_to/gui3d
  74494. */
  74495. export class GUI3DManager implements BABYLON.IDisposable {
  74496. private _scene;
  74497. private _sceneDisposeObserver;
  74498. private _utilityLayer;
  74499. private _rootContainer;
  74500. private _pointerObserver;
  74501. private _pointerOutObserver;
  74502. /** @hidden */
  74503. _lastPickedControl: Control3D;
  74504. /** @hidden */
  74505. _lastControlOver: {
  74506. [pointerId: number]: Control3D;
  74507. };
  74508. /** @hidden */
  74509. _lastControlDown: {
  74510. [pointerId: number]: Control3D;
  74511. };
  74512. /**
  74513. * BABYLON.Observable raised when the point picked by the pointer events changed
  74514. */
  74515. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74516. /** @hidden */
  74517. _sharedMaterials: {
  74518. [key: string]: BABYLON.Material;
  74519. };
  74520. /** Gets the hosting scene */
  74521. get scene(): BABYLON.Scene;
  74522. /** Gets associated utility layer */
  74523. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74524. /**
  74525. * Creates a new GUI3DManager
  74526. * @param scene
  74527. */
  74528. constructor(scene?: BABYLON.Scene);
  74529. private _handlePointerOut;
  74530. private _doPicking;
  74531. /**
  74532. * Gets the root container
  74533. */
  74534. get rootContainer(): Container3D;
  74535. /**
  74536. * Gets a boolean indicating if the given control is in the root child list
  74537. * @param control defines the control to check
  74538. * @returns true if the control is in the root child list
  74539. */
  74540. containsControl(control: Control3D): boolean;
  74541. /**
  74542. * Adds a control to the root child list
  74543. * @param control defines the control to add
  74544. * @returns the current manager
  74545. */
  74546. addControl(control: Control3D): GUI3DManager;
  74547. /**
  74548. * Removes a control from the root child list
  74549. * @param control defines the control to remove
  74550. * @returns the current container
  74551. */
  74552. removeControl(control: Control3D): GUI3DManager;
  74553. /**
  74554. * Releases all associated resources
  74555. */
  74556. dispose(): void;
  74557. }
  74558. }
  74559. declare module BABYLON.GUI {
  74560. /**
  74561. * Class used to transport BABYLON.Vector3 information for pointer events
  74562. */
  74563. export class Vector3WithInfo extends BABYLON.Vector3 {
  74564. /** defines the current mouse button index */
  74565. buttonIndex: number;
  74566. /**
  74567. * Creates a new Vector3WithInfo
  74568. * @param source defines the vector3 data to transport
  74569. * @param buttonIndex defines the current mouse button index
  74570. */
  74571. constructor(source: BABYLON.Vector3,
  74572. /** defines the current mouse button index */
  74573. buttonIndex?: number);
  74574. }
  74575. }
  74576. declare module BABYLON.GUI {
  74577. /**
  74578. * Class used as base class for controls
  74579. */
  74580. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74581. /** Defines the control name */
  74582. name?: string | undefined;
  74583. /** @hidden */
  74584. _host: GUI3DManager;
  74585. private _node;
  74586. private _downCount;
  74587. private _enterCount;
  74588. private _downPointerIds;
  74589. private _isVisible;
  74590. /** Gets or sets the control position in world space */
  74591. get position(): BABYLON.Vector3;
  74592. set position(value: BABYLON.Vector3);
  74593. /** Gets or sets the control scaling in world space */
  74594. get scaling(): BABYLON.Vector3;
  74595. set scaling(value: BABYLON.Vector3);
  74596. /** Callback used to start pointer enter animation */
  74597. pointerEnterAnimation: () => void;
  74598. /** Callback used to start pointer out animation */
  74599. pointerOutAnimation: () => void;
  74600. /** Callback used to start pointer down animation */
  74601. pointerDownAnimation: () => void;
  74602. /** Callback used to start pointer up animation */
  74603. pointerUpAnimation: () => void;
  74604. /**
  74605. * An event triggered when the pointer move over the control
  74606. */
  74607. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74608. /**
  74609. * An event triggered when the pointer move out of the control
  74610. */
  74611. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74612. /**
  74613. * An event triggered when the pointer taps the control
  74614. */
  74615. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74616. /**
  74617. * An event triggered when pointer is up
  74618. */
  74619. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74620. /**
  74621. * An event triggered when a control is clicked on (with a mouse)
  74622. */
  74623. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74624. /**
  74625. * An event triggered when pointer enters the control
  74626. */
  74627. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74628. /**
  74629. * Gets or sets the parent container
  74630. */
  74631. parent: BABYLON.Nullable<Container3D>;
  74632. private _behaviors;
  74633. /**
  74634. * Gets the list of attached behaviors
  74635. * @see http://doc.babylonjs.com/features/behaviour
  74636. */
  74637. get behaviors(): BABYLON.Behavior<Control3D>[];
  74638. /**
  74639. * Attach a behavior to the control
  74640. * @see http://doc.babylonjs.com/features/behaviour
  74641. * @param behavior defines the behavior to attach
  74642. * @returns the current control
  74643. */
  74644. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74645. /**
  74646. * Remove an attached behavior
  74647. * @see http://doc.babylonjs.com/features/behaviour
  74648. * @param behavior defines the behavior to attach
  74649. * @returns the current control
  74650. */
  74651. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74652. /**
  74653. * Gets an attached behavior by name
  74654. * @param name defines the name of the behavior to look for
  74655. * @see http://doc.babylonjs.com/features/behaviour
  74656. * @returns null if behavior was not found else the requested behavior
  74657. */
  74658. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74659. /** Gets or sets a boolean indicating if the control is visible */
  74660. get isVisible(): boolean;
  74661. set isVisible(value: boolean);
  74662. /**
  74663. * Creates a new control
  74664. * @param name defines the control name
  74665. */
  74666. constructor(
  74667. /** Defines the control name */
  74668. name?: string | undefined);
  74669. /**
  74670. * Gets a string representing the class name
  74671. */
  74672. get typeName(): string;
  74673. /**
  74674. * Get the current class name of the control.
  74675. * @returns current class name
  74676. */
  74677. getClassName(): string;
  74678. protected _getTypeName(): string;
  74679. /**
  74680. * Gets the transform node used by this control
  74681. */
  74682. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74683. /**
  74684. * Gets the mesh used to render this control
  74685. */
  74686. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74687. /**
  74688. * Link the control as child of the given node
  74689. * @param node defines the node to link to. Use null to unlink the control
  74690. * @returns the current control
  74691. */
  74692. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74693. /** @hidden **/
  74694. _prepareNode(scene: BABYLON.Scene): void;
  74695. /**
  74696. * Node creation.
  74697. * Can be overriden by children
  74698. * @param scene defines the scene where the node must be attached
  74699. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74700. */
  74701. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74702. /**
  74703. * Affect a material to the given mesh
  74704. * @param mesh defines the mesh which will represent the control
  74705. */
  74706. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74707. /** @hidden */
  74708. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74709. /** @hidden */
  74710. _onPointerEnter(target: Control3D): boolean;
  74711. /** @hidden */
  74712. _onPointerOut(target: Control3D): void;
  74713. /** @hidden */
  74714. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74715. /** @hidden */
  74716. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74717. /** @hidden */
  74718. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74719. /** @hidden */
  74720. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74721. /** @hidden */
  74722. _disposeNode(): void;
  74723. /**
  74724. * Releases all associated resources
  74725. */
  74726. dispose(): void;
  74727. }
  74728. }
  74729. declare module BABYLON.GUI {
  74730. /**
  74731. * Class used as a root to all buttons
  74732. */
  74733. export class AbstractButton3D extends Control3D {
  74734. /**
  74735. * Creates a new button
  74736. * @param name defines the control name
  74737. */
  74738. constructor(name?: string);
  74739. protected _getTypeName(): string;
  74740. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74741. }
  74742. }
  74743. declare module BABYLON.GUI {
  74744. /**
  74745. * Class used to create a button in 3D
  74746. */
  74747. export class Button3D extends AbstractButton3D {
  74748. /** @hidden */
  74749. protected _currentMaterial: BABYLON.Material;
  74750. private _facadeTexture;
  74751. private _content;
  74752. private _contentResolution;
  74753. private _contentScaleRatio;
  74754. /**
  74755. * Gets or sets the texture resolution used to render content (512 by default)
  74756. */
  74757. get contentResolution(): BABYLON.int;
  74758. set contentResolution(value: BABYLON.int);
  74759. /**
  74760. * Gets or sets the texture scale ratio used to render content (2 by default)
  74761. */
  74762. get contentScaleRatio(): number;
  74763. set contentScaleRatio(value: number);
  74764. protected _disposeFacadeTexture(): void;
  74765. protected _resetContent(): void;
  74766. /**
  74767. * Creates a new button
  74768. * @param name defines the control name
  74769. */
  74770. constructor(name?: string);
  74771. /**
  74772. * Gets or sets the GUI 2D content used to display the button's facade
  74773. */
  74774. get content(): Control;
  74775. set content(value: Control);
  74776. /**
  74777. * Apply the facade texture (created from the content property).
  74778. * This function can be overloaded by child classes
  74779. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74780. */
  74781. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74782. protected _getTypeName(): string;
  74783. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74784. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74785. /**
  74786. * Releases all associated resources
  74787. */
  74788. dispose(): void;
  74789. }
  74790. }
  74791. declare module BABYLON.GUI {
  74792. /**
  74793. * Abstract class used to create a container panel deployed on the surface of a volume
  74794. */
  74795. export abstract class VolumeBasedPanel extends Container3D {
  74796. private _columns;
  74797. private _rows;
  74798. private _rowThenColum;
  74799. private _orientation;
  74800. protected _cellWidth: number;
  74801. protected _cellHeight: number;
  74802. /**
  74803. * Gets or sets the distance between elements
  74804. */
  74805. margin: number;
  74806. /**
  74807. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74808. * | Value | Type | Description |
  74809. * | ----- | ----------------------------------- | ----------- |
  74810. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74811. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74812. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74813. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74814. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74815. */
  74816. get orientation(): number;
  74817. set orientation(value: number);
  74818. /**
  74819. * Gets or sets the number of columns requested (10 by default).
  74820. * The panel will automatically compute the number of rows based on number of child controls.
  74821. */
  74822. get columns(): BABYLON.int;
  74823. set columns(value: BABYLON.int);
  74824. /**
  74825. * Gets or sets a the number of rows requested.
  74826. * The panel will automatically compute the number of columns based on number of child controls.
  74827. */
  74828. get rows(): BABYLON.int;
  74829. set rows(value: BABYLON.int);
  74830. /**
  74831. * Creates new VolumeBasedPanel
  74832. */
  74833. constructor();
  74834. protected _arrangeChildren(): void;
  74835. /** Child classes must implement this function to provide correct control positioning */
  74836. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74837. /** Child classes can implement this function to provide additional processing */
  74838. protected _finalProcessing(): void;
  74839. }
  74840. }
  74841. declare module BABYLON.GUI {
  74842. /**
  74843. * Class used to create a container panel deployed on the surface of a cylinder
  74844. */
  74845. export class CylinderPanel extends VolumeBasedPanel {
  74846. private _radius;
  74847. /**
  74848. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74849. */
  74850. get radius(): BABYLON.float;
  74851. set radius(value: BABYLON.float);
  74852. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74853. private _cylindricalMapping;
  74854. }
  74855. }
  74856. declare module BABYLON.GUI {
  74857. /** @hidden */
  74858. export var fluentVertexShader: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON.GUI {
  74864. /** @hidden */
  74865. export var fluentPixelShader: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module BABYLON.GUI {
  74871. /** @hidden */
  74872. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74873. INNERGLOW: boolean;
  74874. BORDER: boolean;
  74875. HOVERLIGHT: boolean;
  74876. TEXTURE: boolean;
  74877. constructor();
  74878. }
  74879. /**
  74880. * Class used to render controls with fluent desgin
  74881. */
  74882. export class FluentMaterial extends BABYLON.PushMaterial {
  74883. /**
  74884. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74885. */
  74886. innerGlowColorIntensity: number;
  74887. /**
  74888. * Gets or sets the inner glow color (white by default)
  74889. */
  74890. innerGlowColor: BABYLON.Color3;
  74891. /**
  74892. * Gets or sets alpha value (default is 1.0)
  74893. */
  74894. alpha: number;
  74895. /**
  74896. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74897. */
  74898. albedoColor: BABYLON.Color3;
  74899. /**
  74900. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74901. */
  74902. renderBorders: boolean;
  74903. /**
  74904. * Gets or sets border width (default is 0.5)
  74905. */
  74906. borderWidth: number;
  74907. /**
  74908. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74909. */
  74910. edgeSmoothingValue: number;
  74911. /**
  74912. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74913. */
  74914. borderMinValue: number;
  74915. /**
  74916. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74917. */
  74918. renderHoverLight: boolean;
  74919. /**
  74920. * Gets or sets the radius used to render the hover light (default is 1.0)
  74921. */
  74922. hoverRadius: number;
  74923. /**
  74924. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74925. */
  74926. hoverColor: BABYLON.Color4;
  74927. /**
  74928. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74929. */
  74930. hoverPosition: BABYLON.Vector3;
  74931. private _albedoTexture;
  74932. /** Gets or sets the texture to use for albedo color */
  74933. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74934. /**
  74935. * Creates a new Fluent material
  74936. * @param name defines the name of the material
  74937. * @param scene defines the hosting scene
  74938. */
  74939. constructor(name: string, scene: BABYLON.Scene);
  74940. needAlphaBlending(): boolean;
  74941. needAlphaTesting(): boolean;
  74942. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74943. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74944. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74945. getActiveTextures(): BABYLON.BaseTexture[];
  74946. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74947. dispose(forceDisposeEffect?: boolean): void;
  74948. clone(name: string): FluentMaterial;
  74949. serialize(): any;
  74950. getClassName(): string;
  74951. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74952. }
  74953. }
  74954. declare module BABYLON.GUI {
  74955. /**
  74956. * Class used to create a holographic button in 3D
  74957. */
  74958. export class HolographicButton extends Button3D {
  74959. private _backPlate;
  74960. private _textPlate;
  74961. private _frontPlate;
  74962. private _text;
  74963. private _imageUrl;
  74964. private _shareMaterials;
  74965. private _frontMaterial;
  74966. private _backMaterial;
  74967. private _plateMaterial;
  74968. private _pickedPointObserver;
  74969. private _tooltipFade;
  74970. private _tooltipTextBlock;
  74971. private _tooltipTexture;
  74972. private _tooltipMesh;
  74973. private _tooltipHoverObserver;
  74974. private _tooltipOutObserver;
  74975. private _disposeTooltip;
  74976. /**
  74977. * Rendering ground id of all the mesh in the button
  74978. */
  74979. set renderingGroupId(id: number);
  74980. get renderingGroupId(): number;
  74981. /**
  74982. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74983. */
  74984. set tooltipText(text: BABYLON.Nullable<string>);
  74985. get tooltipText(): BABYLON.Nullable<string>;
  74986. /**
  74987. * Gets or sets text for the button
  74988. */
  74989. get text(): string;
  74990. set text(value: string);
  74991. /**
  74992. * Gets or sets the image url for the button
  74993. */
  74994. get imageUrl(): string;
  74995. set imageUrl(value: string);
  74996. /**
  74997. * Gets the back material used by this button
  74998. */
  74999. get backMaterial(): FluentMaterial;
  75000. /**
  75001. * Gets the front material used by this button
  75002. */
  75003. get frontMaterial(): FluentMaterial;
  75004. /**
  75005. * Gets the plate material used by this button
  75006. */
  75007. get plateMaterial(): BABYLON.StandardMaterial;
  75008. /**
  75009. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75010. */
  75011. get shareMaterials(): boolean;
  75012. /**
  75013. * Creates a new button
  75014. * @param name defines the control name
  75015. */
  75016. constructor(name?: string, shareMaterials?: boolean);
  75017. protected _getTypeName(): string;
  75018. private _rebuildContent;
  75019. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75020. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75021. private _createBackMaterial;
  75022. private _createFrontMaterial;
  75023. private _createPlateMaterial;
  75024. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75025. /**
  75026. * Releases all associated resources
  75027. */
  75028. dispose(): void;
  75029. }
  75030. }
  75031. declare module BABYLON.GUI {
  75032. /**
  75033. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75034. */
  75035. export class MeshButton3D extends Button3D {
  75036. /** @hidden */
  75037. protected _currentMesh: BABYLON.Mesh;
  75038. /**
  75039. * Creates a new 3D button based on a mesh
  75040. * @param mesh mesh to become a 3D button
  75041. * @param name defines the control name
  75042. */
  75043. constructor(mesh: BABYLON.Mesh, name?: string);
  75044. protected _getTypeName(): string;
  75045. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75046. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75047. }
  75048. }
  75049. declare module BABYLON.GUI {
  75050. /**
  75051. * Class used to create a container panel deployed on the surface of a plane
  75052. */
  75053. export class PlanePanel extends VolumeBasedPanel {
  75054. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75055. }
  75056. }
  75057. declare module BABYLON.GUI {
  75058. /**
  75059. * Class used to create a container panel where items get randomized planar mapping
  75060. */
  75061. export class ScatterPanel extends VolumeBasedPanel {
  75062. private _iteration;
  75063. /**
  75064. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75065. */
  75066. get iteration(): BABYLON.float;
  75067. set iteration(value: BABYLON.float);
  75068. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75069. private _scatterMapping;
  75070. protected _finalProcessing(): void;
  75071. }
  75072. }
  75073. declare module BABYLON.GUI {
  75074. /**
  75075. * Class used to create a container panel deployed on the surface of a sphere
  75076. */
  75077. export class SpherePanel extends VolumeBasedPanel {
  75078. private _radius;
  75079. /**
  75080. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75081. */
  75082. get radius(): BABYLON.float;
  75083. set radius(value: BABYLON.float);
  75084. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75085. private _sphericalMapping;
  75086. }
  75087. }
  75088. declare module BABYLON.GUI {
  75089. /**
  75090. * Class used to create a stack panel in 3D on XY plane
  75091. */
  75092. export class StackPanel3D extends Container3D {
  75093. private _isVertical;
  75094. /**
  75095. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75096. */
  75097. get isVertical(): boolean;
  75098. set isVertical(value: boolean);
  75099. /**
  75100. * Gets or sets the distance between elements
  75101. */
  75102. margin: number;
  75103. /**
  75104. * Creates new StackPanel
  75105. * @param isVertical
  75106. */
  75107. constructor(isVertical?: boolean);
  75108. protected _arrangeChildren(): void;
  75109. }
  75110. }
  75111. declare module BABYLON {
  75112. /**
  75113. * Configuration for glTF validation
  75114. */
  75115. export interface IGLTFValidationConfiguration {
  75116. /**
  75117. * The url of the glTF validator.
  75118. */
  75119. url: string;
  75120. }
  75121. /**
  75122. * glTF validation
  75123. */
  75124. export class GLTFValidation {
  75125. /**
  75126. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75127. */
  75128. static Configuration: IGLTFValidationConfiguration;
  75129. private static _LoadScriptPromise;
  75130. /**
  75131. * Validate a glTF asset using the glTF-Validator.
  75132. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75133. * @param rootUrl The root url for the glTF
  75134. * @param fileName The file name for the glTF
  75135. * @param getExternalResource The callback to get external resources for the glTF validator
  75136. * @returns A promise that resolves with the glTF validation results once complete
  75137. */
  75138. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75139. }
  75140. }
  75141. declare module BABYLON {
  75142. /**
  75143. * Mode that determines the coordinate system to use.
  75144. */
  75145. export enum GLTFLoaderCoordinateSystemMode {
  75146. /**
  75147. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75148. */
  75149. AUTO = 0,
  75150. /**
  75151. * Sets the useRightHandedSystem flag on the scene.
  75152. */
  75153. FORCE_RIGHT_HANDED = 1
  75154. }
  75155. /**
  75156. * Mode that determines what animations will start.
  75157. */
  75158. export enum GLTFLoaderAnimationStartMode {
  75159. /**
  75160. * No animation will start.
  75161. */
  75162. NONE = 0,
  75163. /**
  75164. * The first animation will start.
  75165. */
  75166. FIRST = 1,
  75167. /**
  75168. * All animations will start.
  75169. */
  75170. ALL = 2
  75171. }
  75172. /**
  75173. * Interface that contains the data for the glTF asset.
  75174. */
  75175. export interface IGLTFLoaderData {
  75176. /**
  75177. * The object that represents the glTF JSON.
  75178. */
  75179. json: Object;
  75180. /**
  75181. * The BIN chunk of a binary glTF.
  75182. */
  75183. bin: Nullable<IDataBuffer>;
  75184. }
  75185. /**
  75186. * Interface for extending the loader.
  75187. */
  75188. export interface IGLTFLoaderExtension {
  75189. /**
  75190. * The name of this extension.
  75191. */
  75192. readonly name: string;
  75193. /**
  75194. * Defines whether this extension is enabled.
  75195. */
  75196. enabled: boolean;
  75197. /**
  75198. * Defines the order of this extension.
  75199. * The loader sorts the extensions using these values when loading.
  75200. */
  75201. order?: number;
  75202. }
  75203. /**
  75204. * Loader state.
  75205. */
  75206. export enum GLTFLoaderState {
  75207. /**
  75208. * The asset is loading.
  75209. */
  75210. LOADING = 0,
  75211. /**
  75212. * The asset is ready for rendering.
  75213. */
  75214. READY = 1,
  75215. /**
  75216. * The asset is completely loaded.
  75217. */
  75218. COMPLETE = 2
  75219. }
  75220. /** @hidden */
  75221. export interface IImportMeshAsyncOutput {
  75222. meshes: AbstractMesh[];
  75223. particleSystems: IParticleSystem[];
  75224. skeletons: Skeleton[];
  75225. animationGroups: AnimationGroup[];
  75226. lights: Light[];
  75227. transformNodes: TransformNode[];
  75228. }
  75229. /** @hidden */
  75230. export interface IGLTFLoader extends IDisposable {
  75231. readonly state: Nullable<GLTFLoaderState>;
  75232. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75233. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75234. }
  75235. /**
  75236. * File loader for loading glTF files into a scene.
  75237. */
  75238. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75239. /** @hidden */
  75240. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75241. /** @hidden */
  75242. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75243. /**
  75244. * Raised when the asset has been parsed
  75245. */
  75246. onParsedObservable: Observable<IGLTFLoaderData>;
  75247. private _onParsedObserver;
  75248. /**
  75249. * Raised when the asset has been parsed
  75250. */
  75251. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75252. /**
  75253. * 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.
  75254. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75255. * Defaults to true.
  75256. * @hidden
  75257. */
  75258. static IncrementalLoading: boolean;
  75259. /**
  75260. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75261. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75262. * @hidden
  75263. */
  75264. static HomogeneousCoordinates: boolean;
  75265. /**
  75266. * The coordinate system mode. Defaults to AUTO.
  75267. */
  75268. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75269. /**
  75270. * The animation start mode. Defaults to FIRST.
  75271. */
  75272. animationStartMode: GLTFLoaderAnimationStartMode;
  75273. /**
  75274. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75275. */
  75276. compileMaterials: boolean;
  75277. /**
  75278. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75279. */
  75280. useClipPlane: boolean;
  75281. /**
  75282. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75283. */
  75284. compileShadowGenerators: boolean;
  75285. /**
  75286. * Defines if the Alpha blended materials are only applied as coverage.
  75287. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75288. * If true, no extra effects are applied to transparent pixels.
  75289. */
  75290. transparencyAsCoverage: boolean;
  75291. /**
  75292. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75293. * Enabling will disable offline support and glTF validator.
  75294. * Defaults to false.
  75295. */
  75296. useRangeRequests: boolean;
  75297. /**
  75298. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75299. */
  75300. createInstances: boolean;
  75301. /**
  75302. * Function called before loading a url referenced by the asset.
  75303. */
  75304. preprocessUrlAsync: (url: string) => Promise<string>;
  75305. /**
  75306. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75307. */
  75308. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75309. private _onMeshLoadedObserver;
  75310. /**
  75311. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75312. */
  75313. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75314. /**
  75315. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75316. */
  75317. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75318. private _onTextureLoadedObserver;
  75319. /**
  75320. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75321. */
  75322. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75323. /**
  75324. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75325. */
  75326. readonly onMaterialLoadedObservable: Observable<Material>;
  75327. private _onMaterialLoadedObserver;
  75328. /**
  75329. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75330. */
  75331. set onMaterialLoaded(callback: (material: Material) => void);
  75332. /**
  75333. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75334. */
  75335. readonly onCameraLoadedObservable: Observable<Camera>;
  75336. private _onCameraLoadedObserver;
  75337. /**
  75338. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75339. */
  75340. set onCameraLoaded(callback: (camera: Camera) => void);
  75341. /**
  75342. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75343. * For assets with LODs, raised when all of the LODs are complete.
  75344. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75345. */
  75346. readonly onCompleteObservable: Observable<void>;
  75347. private _onCompleteObserver;
  75348. /**
  75349. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75350. * For assets with LODs, raised when all of the LODs are complete.
  75351. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75352. */
  75353. set onComplete(callback: () => void);
  75354. /**
  75355. * Observable raised when an error occurs.
  75356. */
  75357. readonly onErrorObservable: Observable<any>;
  75358. private _onErrorObserver;
  75359. /**
  75360. * Callback raised when an error occurs.
  75361. */
  75362. set onError(callback: (reason: any) => void);
  75363. /**
  75364. * Observable raised after the loader is disposed.
  75365. */
  75366. readonly onDisposeObservable: Observable<void>;
  75367. private _onDisposeObserver;
  75368. /**
  75369. * Callback raised after the loader is disposed.
  75370. */
  75371. set onDispose(callback: () => void);
  75372. /**
  75373. * Observable raised after a loader extension is created.
  75374. * Set additional options for a loader extension in this event.
  75375. */
  75376. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75377. private _onExtensionLoadedObserver;
  75378. /**
  75379. * Callback raised after a loader extension is created.
  75380. */
  75381. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75382. /**
  75383. * Defines if the loader logging is enabled.
  75384. */
  75385. get loggingEnabled(): boolean;
  75386. set loggingEnabled(value: boolean);
  75387. /**
  75388. * Defines if the loader should capture performance counters.
  75389. */
  75390. get capturePerformanceCounters(): boolean;
  75391. set capturePerformanceCounters(value: boolean);
  75392. /**
  75393. * Defines if the loader should validate the asset.
  75394. */
  75395. validate: boolean;
  75396. /**
  75397. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75398. */
  75399. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75400. private _onValidatedObserver;
  75401. /**
  75402. * Callback raised after a loader extension is created.
  75403. */
  75404. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75405. private _loader;
  75406. /**
  75407. * Name of the loader ("gltf")
  75408. */
  75409. name: string;
  75410. /** @hidden */
  75411. extensions: ISceneLoaderPluginExtensions;
  75412. /**
  75413. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75414. */
  75415. dispose(): void;
  75416. /** @hidden */
  75417. _clear(): void;
  75418. /** @hidden */
  75419. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75420. /** @hidden */
  75421. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75422. /** @hidden */
  75423. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75424. meshes: AbstractMesh[];
  75425. particleSystems: IParticleSystem[];
  75426. skeletons: Skeleton[];
  75427. animationGroups: AnimationGroup[];
  75428. }>;
  75429. /** @hidden */
  75430. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75431. /** @hidden */
  75432. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75433. /** @hidden */
  75434. canDirectLoad(data: string): boolean;
  75435. /** @hidden */
  75436. directLoad(scene: Scene, data: string): any;
  75437. /**
  75438. * The callback that allows custom handling of the root url based on the response url.
  75439. * @param rootUrl the original root url
  75440. * @param responseURL the response url if available
  75441. * @returns the new root url
  75442. */
  75443. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75444. /** @hidden */
  75445. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75446. /**
  75447. * The loader state or null if the loader is not active.
  75448. */
  75449. get loaderState(): Nullable<GLTFLoaderState>;
  75450. /**
  75451. * Returns a promise that resolves when the asset is completely loaded.
  75452. * @returns a promise that resolves when the asset is completely loaded.
  75453. */
  75454. whenCompleteAsync(): Promise<void>;
  75455. private _validate;
  75456. private _getLoader;
  75457. private _parseJson;
  75458. private _unpackBinaryAsync;
  75459. private _unpackBinaryV1Async;
  75460. private _unpackBinaryV2Async;
  75461. private static _parseVersion;
  75462. private static _compareVersion;
  75463. private static readonly _logSpaces;
  75464. private _logIndentLevel;
  75465. private _loggingEnabled;
  75466. /** @hidden */
  75467. _log: (message: string) => void;
  75468. /** @hidden */
  75469. _logOpen(message: string): void;
  75470. /** @hidden */
  75471. _logClose(): void;
  75472. private _logEnabled;
  75473. private _logDisabled;
  75474. private _capturePerformanceCounters;
  75475. /** @hidden */
  75476. _startPerformanceCounter: (counterName: string) => void;
  75477. /** @hidden */
  75478. _endPerformanceCounter: (counterName: string) => void;
  75479. private _startPerformanceCounterEnabled;
  75480. private _startPerformanceCounterDisabled;
  75481. private _endPerformanceCounterEnabled;
  75482. private _endPerformanceCounterDisabled;
  75483. }
  75484. }
  75485. declare module BABYLON.GLTF1 {
  75486. /**
  75487. * Enums
  75488. * @hidden
  75489. */
  75490. export enum EComponentType {
  75491. BYTE = 5120,
  75492. UNSIGNED_BYTE = 5121,
  75493. SHORT = 5122,
  75494. UNSIGNED_SHORT = 5123,
  75495. FLOAT = 5126
  75496. }
  75497. /** @hidden */
  75498. export enum EShaderType {
  75499. FRAGMENT = 35632,
  75500. VERTEX = 35633
  75501. }
  75502. /** @hidden */
  75503. export enum EParameterType {
  75504. BYTE = 5120,
  75505. UNSIGNED_BYTE = 5121,
  75506. SHORT = 5122,
  75507. UNSIGNED_SHORT = 5123,
  75508. INT = 5124,
  75509. UNSIGNED_INT = 5125,
  75510. FLOAT = 5126,
  75511. FLOAT_VEC2 = 35664,
  75512. FLOAT_VEC3 = 35665,
  75513. FLOAT_VEC4 = 35666,
  75514. INT_VEC2 = 35667,
  75515. INT_VEC3 = 35668,
  75516. INT_VEC4 = 35669,
  75517. BOOL = 35670,
  75518. BOOL_VEC2 = 35671,
  75519. BOOL_VEC3 = 35672,
  75520. BOOL_VEC4 = 35673,
  75521. FLOAT_MAT2 = 35674,
  75522. FLOAT_MAT3 = 35675,
  75523. FLOAT_MAT4 = 35676,
  75524. SAMPLER_2D = 35678
  75525. }
  75526. /** @hidden */
  75527. export enum ETextureWrapMode {
  75528. CLAMP_TO_EDGE = 33071,
  75529. MIRRORED_REPEAT = 33648,
  75530. REPEAT = 10497
  75531. }
  75532. /** @hidden */
  75533. export enum ETextureFilterType {
  75534. NEAREST = 9728,
  75535. LINEAR = 9728,
  75536. NEAREST_MIPMAP_NEAREST = 9984,
  75537. LINEAR_MIPMAP_NEAREST = 9985,
  75538. NEAREST_MIPMAP_LINEAR = 9986,
  75539. LINEAR_MIPMAP_LINEAR = 9987
  75540. }
  75541. /** @hidden */
  75542. export enum ETextureFormat {
  75543. ALPHA = 6406,
  75544. RGB = 6407,
  75545. RGBA = 6408,
  75546. LUMINANCE = 6409,
  75547. LUMINANCE_ALPHA = 6410
  75548. }
  75549. /** @hidden */
  75550. export enum ECullingType {
  75551. FRONT = 1028,
  75552. BACK = 1029,
  75553. FRONT_AND_BACK = 1032
  75554. }
  75555. /** @hidden */
  75556. export enum EBlendingFunction {
  75557. ZERO = 0,
  75558. ONE = 1,
  75559. SRC_COLOR = 768,
  75560. ONE_MINUS_SRC_COLOR = 769,
  75561. DST_COLOR = 774,
  75562. ONE_MINUS_DST_COLOR = 775,
  75563. SRC_ALPHA = 770,
  75564. ONE_MINUS_SRC_ALPHA = 771,
  75565. DST_ALPHA = 772,
  75566. ONE_MINUS_DST_ALPHA = 773,
  75567. CONSTANT_COLOR = 32769,
  75568. ONE_MINUS_CONSTANT_COLOR = 32770,
  75569. CONSTANT_ALPHA = 32771,
  75570. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75571. SRC_ALPHA_SATURATE = 776
  75572. }
  75573. /** @hidden */
  75574. export interface IGLTFProperty {
  75575. extensions?: {
  75576. [key: string]: any;
  75577. };
  75578. extras?: Object;
  75579. }
  75580. /** @hidden */
  75581. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75582. name?: string;
  75583. }
  75584. /** @hidden */
  75585. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75586. bufferView: string;
  75587. byteOffset: number;
  75588. byteStride: number;
  75589. count: number;
  75590. type: string;
  75591. componentType: EComponentType;
  75592. max?: number[];
  75593. min?: number[];
  75594. name?: string;
  75595. }
  75596. /** @hidden */
  75597. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75598. buffer: string;
  75599. byteOffset: number;
  75600. byteLength: number;
  75601. byteStride: number;
  75602. target?: number;
  75603. }
  75604. /** @hidden */
  75605. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75606. uri: string;
  75607. byteLength?: number;
  75608. type?: string;
  75609. }
  75610. /** @hidden */
  75611. export interface IGLTFShader extends IGLTFChildRootProperty {
  75612. uri: string;
  75613. type: EShaderType;
  75614. }
  75615. /** @hidden */
  75616. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75617. attributes: string[];
  75618. fragmentShader: string;
  75619. vertexShader: string;
  75620. }
  75621. /** @hidden */
  75622. export interface IGLTFTechniqueParameter {
  75623. type: number;
  75624. count?: number;
  75625. semantic?: string;
  75626. node?: string;
  75627. value?: number | boolean | string | Array<any>;
  75628. source?: string;
  75629. babylonValue?: any;
  75630. }
  75631. /** @hidden */
  75632. export interface IGLTFTechniqueCommonProfile {
  75633. lightingModel: string;
  75634. texcoordBindings: Object;
  75635. parameters?: Array<any>;
  75636. }
  75637. /** @hidden */
  75638. export interface IGLTFTechniqueStatesFunctions {
  75639. blendColor?: number[];
  75640. blendEquationSeparate?: number[];
  75641. blendFuncSeparate?: number[];
  75642. colorMask: boolean[];
  75643. cullFace: number[];
  75644. }
  75645. /** @hidden */
  75646. export interface IGLTFTechniqueStates {
  75647. enable: number[];
  75648. functions: IGLTFTechniqueStatesFunctions;
  75649. }
  75650. /** @hidden */
  75651. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75652. parameters: {
  75653. [key: string]: IGLTFTechniqueParameter;
  75654. };
  75655. program: string;
  75656. attributes: {
  75657. [key: string]: string;
  75658. };
  75659. uniforms: {
  75660. [key: string]: string;
  75661. };
  75662. states: IGLTFTechniqueStates;
  75663. }
  75664. /** @hidden */
  75665. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75666. technique?: string;
  75667. values: string[];
  75668. }
  75669. /** @hidden */
  75670. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75671. attributes: {
  75672. [key: string]: string;
  75673. };
  75674. indices: string;
  75675. material: string;
  75676. mode?: number;
  75677. }
  75678. /** @hidden */
  75679. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75680. primitives: IGLTFMeshPrimitive[];
  75681. }
  75682. /** @hidden */
  75683. export interface IGLTFImage extends IGLTFChildRootProperty {
  75684. uri: string;
  75685. }
  75686. /** @hidden */
  75687. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75688. magFilter?: number;
  75689. minFilter?: number;
  75690. wrapS?: number;
  75691. wrapT?: number;
  75692. }
  75693. /** @hidden */
  75694. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75695. sampler: string;
  75696. source: string;
  75697. format?: ETextureFormat;
  75698. internalFormat?: ETextureFormat;
  75699. target?: number;
  75700. type?: number;
  75701. babylonTexture?: Texture;
  75702. }
  75703. /** @hidden */
  75704. export interface IGLTFAmbienLight {
  75705. color?: number[];
  75706. }
  75707. /** @hidden */
  75708. export interface IGLTFDirectionalLight {
  75709. color?: number[];
  75710. }
  75711. /** @hidden */
  75712. export interface IGLTFPointLight {
  75713. color?: number[];
  75714. constantAttenuation?: number;
  75715. linearAttenuation?: number;
  75716. quadraticAttenuation?: number;
  75717. }
  75718. /** @hidden */
  75719. export interface IGLTFSpotLight {
  75720. color?: number[];
  75721. constantAttenuation?: number;
  75722. fallOfAngle?: number;
  75723. fallOffExponent?: number;
  75724. linearAttenuation?: number;
  75725. quadraticAttenuation?: number;
  75726. }
  75727. /** @hidden */
  75728. export interface IGLTFLight extends IGLTFChildRootProperty {
  75729. type: string;
  75730. }
  75731. /** @hidden */
  75732. export interface IGLTFCameraOrthographic {
  75733. xmag: number;
  75734. ymag: number;
  75735. zfar: number;
  75736. znear: number;
  75737. }
  75738. /** @hidden */
  75739. export interface IGLTFCameraPerspective {
  75740. aspectRatio: number;
  75741. yfov: number;
  75742. zfar: number;
  75743. znear: number;
  75744. }
  75745. /** @hidden */
  75746. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75747. type: string;
  75748. }
  75749. /** @hidden */
  75750. export interface IGLTFAnimationChannelTarget {
  75751. id: string;
  75752. path: string;
  75753. }
  75754. /** @hidden */
  75755. export interface IGLTFAnimationChannel {
  75756. sampler: string;
  75757. target: IGLTFAnimationChannelTarget;
  75758. }
  75759. /** @hidden */
  75760. export interface IGLTFAnimationSampler {
  75761. input: string;
  75762. output: string;
  75763. interpolation?: string;
  75764. }
  75765. /** @hidden */
  75766. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75767. channels?: IGLTFAnimationChannel[];
  75768. parameters?: {
  75769. [key: string]: string;
  75770. };
  75771. samplers?: {
  75772. [key: string]: IGLTFAnimationSampler;
  75773. };
  75774. }
  75775. /** @hidden */
  75776. export interface IGLTFNodeInstanceSkin {
  75777. skeletons: string[];
  75778. skin: string;
  75779. meshes: string[];
  75780. }
  75781. /** @hidden */
  75782. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75783. bindShapeMatrix: number[];
  75784. inverseBindMatrices: string;
  75785. jointNames: string[];
  75786. babylonSkeleton?: Skeleton;
  75787. }
  75788. /** @hidden */
  75789. export interface IGLTFNode extends IGLTFChildRootProperty {
  75790. camera?: string;
  75791. children: string[];
  75792. skin?: string;
  75793. jointName?: string;
  75794. light?: string;
  75795. matrix: number[];
  75796. mesh?: string;
  75797. meshes?: string[];
  75798. rotation?: number[];
  75799. scale?: number[];
  75800. translation?: number[];
  75801. babylonNode?: Node;
  75802. }
  75803. /** @hidden */
  75804. export interface IGLTFScene extends IGLTFChildRootProperty {
  75805. nodes: string[];
  75806. }
  75807. /** @hidden */
  75808. export interface IGLTFRuntime {
  75809. extensions: {
  75810. [key: string]: any;
  75811. };
  75812. accessors: {
  75813. [key: string]: IGLTFAccessor;
  75814. };
  75815. buffers: {
  75816. [key: string]: IGLTFBuffer;
  75817. };
  75818. bufferViews: {
  75819. [key: string]: IGLTFBufferView;
  75820. };
  75821. meshes: {
  75822. [key: string]: IGLTFMesh;
  75823. };
  75824. lights: {
  75825. [key: string]: IGLTFLight;
  75826. };
  75827. cameras: {
  75828. [key: string]: IGLTFCamera;
  75829. };
  75830. nodes: {
  75831. [key: string]: IGLTFNode;
  75832. };
  75833. images: {
  75834. [key: string]: IGLTFImage;
  75835. };
  75836. textures: {
  75837. [key: string]: IGLTFTexture;
  75838. };
  75839. shaders: {
  75840. [key: string]: IGLTFShader;
  75841. };
  75842. programs: {
  75843. [key: string]: IGLTFProgram;
  75844. };
  75845. samplers: {
  75846. [key: string]: IGLTFSampler;
  75847. };
  75848. techniques: {
  75849. [key: string]: IGLTFTechnique;
  75850. };
  75851. materials: {
  75852. [key: string]: IGLTFMaterial;
  75853. };
  75854. animations: {
  75855. [key: string]: IGLTFAnimation;
  75856. };
  75857. skins: {
  75858. [key: string]: IGLTFSkins;
  75859. };
  75860. currentScene?: Object;
  75861. scenes: {
  75862. [key: string]: IGLTFScene;
  75863. };
  75864. extensionsUsed: string[];
  75865. extensionsRequired?: string[];
  75866. buffersCount: number;
  75867. shaderscount: number;
  75868. scene: Scene;
  75869. rootUrl: string;
  75870. loadedBufferCount: number;
  75871. loadedBufferViews: {
  75872. [name: string]: ArrayBufferView;
  75873. };
  75874. loadedShaderCount: number;
  75875. importOnlyMeshes: boolean;
  75876. importMeshesNames?: string[];
  75877. dummyNodes: Node[];
  75878. forAssetContainer: boolean;
  75879. }
  75880. /** @hidden */
  75881. export interface INodeToRoot {
  75882. bone: Bone;
  75883. node: IGLTFNode;
  75884. id: string;
  75885. }
  75886. /** @hidden */
  75887. export interface IJointNode {
  75888. node: IGLTFNode;
  75889. id: string;
  75890. }
  75891. }
  75892. declare module BABYLON.GLTF1 {
  75893. /**
  75894. * Utils functions for GLTF
  75895. * @hidden
  75896. */
  75897. export class GLTFUtils {
  75898. /**
  75899. * Sets the given "parameter" matrix
  75900. * @param scene: the Scene object
  75901. * @param source: the source node where to pick the matrix
  75902. * @param parameter: the GLTF technique parameter
  75903. * @param uniformName: the name of the shader's uniform
  75904. * @param shaderMaterial: the shader material
  75905. */
  75906. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75907. /**
  75908. * Sets the given "parameter" matrix
  75909. * @param shaderMaterial: the shader material
  75910. * @param uniform: the name of the shader's uniform
  75911. * @param value: the value of the uniform
  75912. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75913. */
  75914. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75915. /**
  75916. * Returns the wrap mode of the texture
  75917. * @param mode: the mode value
  75918. */
  75919. static GetWrapMode(mode: number): number;
  75920. /**
  75921. * Returns the byte stride giving an accessor
  75922. * @param accessor: the GLTF accessor objet
  75923. */
  75924. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75925. /**
  75926. * Returns the texture filter mode giving a mode value
  75927. * @param mode: the filter mode value
  75928. */
  75929. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75930. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75931. /**
  75932. * Returns a buffer from its accessor
  75933. * @param gltfRuntime: the GLTF runtime
  75934. * @param accessor: the GLTF accessor
  75935. */
  75936. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75937. /**
  75938. * Decodes a buffer view into a string
  75939. * @param view: the buffer view
  75940. */
  75941. static DecodeBufferToText(view: ArrayBufferView): string;
  75942. /**
  75943. * Returns the default material of gltf. Related to
  75944. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75945. * @param scene: the Babylon.js scene
  75946. */
  75947. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75948. private static _DefaultMaterial;
  75949. }
  75950. }
  75951. declare module BABYLON.GLTF1 {
  75952. /**
  75953. * Implementation of the base glTF spec
  75954. * @hidden
  75955. */
  75956. export class GLTFLoaderBase {
  75957. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75958. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75959. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75960. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75961. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75962. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75963. }
  75964. /**
  75965. * glTF V1 Loader
  75966. * @hidden
  75967. */
  75968. export class GLTFLoader implements IGLTFLoader {
  75969. static Extensions: {
  75970. [name: string]: GLTFLoaderExtension;
  75971. };
  75972. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75973. state: Nullable<GLTFLoaderState>;
  75974. dispose(): void;
  75975. private _importMeshAsync;
  75976. /**
  75977. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75978. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75979. * @param scene the scene the meshes should be added to
  75980. * @param forAssetContainer defines if the entities must be stored in the scene
  75981. * @param data gltf data containing information of the meshes in a loaded file
  75982. * @param rootUrl root url to load from
  75983. * @param onProgress event that fires when loading progress has occured
  75984. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75985. */
  75986. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75987. private _loadAsync;
  75988. /**
  75989. * Imports all objects from a loaded gltf file and adds them to the scene
  75990. * @param scene the scene the objects should be added to
  75991. * @param data gltf data containing information of the meshes in a loaded file
  75992. * @param rootUrl root url to load from
  75993. * @param onProgress event that fires when loading progress has occured
  75994. * @returns a promise which completes when objects have been loaded to the scene
  75995. */
  75996. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75997. private _loadShadersAsync;
  75998. private _loadBuffersAsync;
  75999. private _createNodes;
  76000. }
  76001. /** @hidden */
  76002. export abstract class GLTFLoaderExtension {
  76003. private _name;
  76004. constructor(name: string);
  76005. get name(): string;
  76006. /**
  76007. * Defines an override for loading the runtime
  76008. * Return true to stop further extensions from loading the runtime
  76009. */
  76010. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76011. /**
  76012. * Defines an onverride for creating gltf runtime
  76013. * Return true to stop further extensions from creating the runtime
  76014. */
  76015. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76016. /**
  76017. * Defines an override for loading buffers
  76018. * Return true to stop further extensions from loading this buffer
  76019. */
  76020. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76021. /**
  76022. * Defines an override for loading texture buffers
  76023. * Return true to stop further extensions from loading this texture data
  76024. */
  76025. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76026. /**
  76027. * Defines an override for creating textures
  76028. * Return true to stop further extensions from loading this texture
  76029. */
  76030. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76031. /**
  76032. * Defines an override for loading shader strings
  76033. * Return true to stop further extensions from loading this shader data
  76034. */
  76035. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76036. /**
  76037. * Defines an override for loading materials
  76038. * Return true to stop further extensions from loading this material
  76039. */
  76040. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76041. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76042. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76043. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76044. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76045. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76046. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76047. private static LoadTextureBufferAsync;
  76048. private static CreateTextureAsync;
  76049. private static ApplyExtensions;
  76050. }
  76051. }
  76052. declare module BABYLON.GLTF1 {
  76053. /** @hidden */
  76054. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76055. private _bin;
  76056. constructor();
  76057. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76058. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76059. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76060. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76061. }
  76062. }
  76063. declare module BABYLON.GLTF1 {
  76064. /** @hidden */
  76065. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76066. constructor();
  76067. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76068. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76069. private _loadTexture;
  76070. }
  76071. }
  76072. declare module BABYLON.GLTF2.Loader {
  76073. /**
  76074. * Loader interface with an index field.
  76075. */
  76076. export interface IArrayItem {
  76077. /**
  76078. * The index of this item in the array.
  76079. */
  76080. index: number;
  76081. }
  76082. /**
  76083. * Loader interface with additional members.
  76084. */
  76085. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76086. /** @hidden */
  76087. _data?: Promise<ArrayBufferView>;
  76088. /** @hidden */
  76089. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76090. }
  76091. /**
  76092. * Loader interface with additional members.
  76093. */
  76094. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76095. }
  76096. /** @hidden */
  76097. export interface _IAnimationSamplerData {
  76098. input: Float32Array;
  76099. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76100. output: Float32Array;
  76101. }
  76102. /**
  76103. * Loader interface with additional members.
  76104. */
  76105. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76106. /** @hidden */
  76107. _data?: Promise<_IAnimationSamplerData>;
  76108. }
  76109. /**
  76110. * Loader interface with additional members.
  76111. */
  76112. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76113. channels: IAnimationChannel[];
  76114. samplers: IAnimationSampler[];
  76115. /** @hidden */
  76116. _babylonAnimationGroup?: AnimationGroup;
  76117. }
  76118. /**
  76119. * Loader interface with additional members.
  76120. */
  76121. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76122. /** @hidden */
  76123. _data?: Promise<ArrayBufferView>;
  76124. }
  76125. /**
  76126. * Loader interface with additional members.
  76127. */
  76128. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76129. /** @hidden */
  76130. _data?: Promise<ArrayBufferView>;
  76131. /** @hidden */
  76132. _babylonBuffer?: Promise<Buffer>;
  76133. }
  76134. /**
  76135. * Loader interface with additional members.
  76136. */
  76137. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76138. }
  76139. /**
  76140. * Loader interface with additional members.
  76141. */
  76142. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76143. /** @hidden */
  76144. _data?: Promise<ArrayBufferView>;
  76145. }
  76146. /**
  76147. * Loader interface with additional members.
  76148. */
  76149. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76150. }
  76151. /**
  76152. * Loader interface with additional members.
  76153. */
  76154. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76155. }
  76156. /**
  76157. * Loader interface with additional members.
  76158. */
  76159. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76160. baseColorTexture?: ITextureInfo;
  76161. metallicRoughnessTexture?: ITextureInfo;
  76162. }
  76163. /**
  76164. * Loader interface with additional members.
  76165. */
  76166. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76167. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76168. normalTexture?: IMaterialNormalTextureInfo;
  76169. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76170. emissiveTexture?: ITextureInfo;
  76171. /** @hidden */
  76172. _data?: {
  76173. [babylonDrawMode: number]: {
  76174. babylonMaterial: Material;
  76175. babylonMeshes: AbstractMesh[];
  76176. promise: Promise<void>;
  76177. };
  76178. };
  76179. }
  76180. /**
  76181. * Loader interface with additional members.
  76182. */
  76183. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76184. primitives: IMeshPrimitive[];
  76185. }
  76186. /**
  76187. * Loader interface with additional members.
  76188. */
  76189. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76190. /** @hidden */
  76191. _instanceData?: {
  76192. babylonSourceMesh: Mesh;
  76193. promise: Promise<any>;
  76194. };
  76195. }
  76196. /**
  76197. * Loader interface with additional members.
  76198. */
  76199. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76200. /**
  76201. * The parent glTF node.
  76202. */
  76203. parent?: INode;
  76204. /** @hidden */
  76205. _babylonTransformNode?: TransformNode;
  76206. /** @hidden */
  76207. _primitiveBabylonMeshes?: AbstractMesh[];
  76208. /** @hidden */
  76209. _babylonBones?: Bone[];
  76210. /** @hidden */
  76211. _numMorphTargets?: number;
  76212. }
  76213. /** @hidden */
  76214. export interface _ISamplerData {
  76215. noMipMaps: boolean;
  76216. samplingMode: number;
  76217. wrapU: number;
  76218. wrapV: number;
  76219. }
  76220. /**
  76221. * Loader interface with additional members.
  76222. */
  76223. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76224. /** @hidden */
  76225. _data?: _ISamplerData;
  76226. }
  76227. /**
  76228. * Loader interface with additional members.
  76229. */
  76230. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76231. }
  76232. /**
  76233. * Loader interface with additional members.
  76234. */
  76235. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76236. /** @hidden */
  76237. _data?: {
  76238. babylonSkeleton: Skeleton;
  76239. promise: Promise<void>;
  76240. };
  76241. }
  76242. /**
  76243. * Loader interface with additional members.
  76244. */
  76245. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76246. }
  76247. /**
  76248. * Loader interface with additional members.
  76249. */
  76250. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76251. }
  76252. /**
  76253. * Loader interface with additional members.
  76254. */
  76255. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76256. accessors?: IAccessor[];
  76257. animations?: IAnimation[];
  76258. buffers?: IBuffer[];
  76259. bufferViews?: IBufferView[];
  76260. cameras?: ICamera[];
  76261. images?: IImage[];
  76262. materials?: IMaterial[];
  76263. meshes?: IMesh[];
  76264. nodes?: INode[];
  76265. samplers?: ISampler[];
  76266. scenes?: IScene[];
  76267. skins?: ISkin[];
  76268. textures?: ITexture[];
  76269. }
  76270. }
  76271. declare module BABYLON.GLTF2 {
  76272. /**
  76273. * Interface for a glTF loader extension.
  76274. */
  76275. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76276. /**
  76277. * Called after the loader state changes to LOADING.
  76278. */
  76279. onLoading?(): void;
  76280. /**
  76281. * Called after the loader state changes to READY.
  76282. */
  76283. onReady?(): void;
  76284. /**
  76285. * Define this method to modify the default behavior when loading scenes.
  76286. * @param context The context when loading the asset
  76287. * @param scene The glTF scene property
  76288. * @returns A promise that resolves when the load is complete or null if not handled
  76289. */
  76290. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76291. /**
  76292. * Define this method to modify the default behavior when loading nodes.
  76293. * @param context The context when loading the asset
  76294. * @param node The glTF node property
  76295. * @param assign A function called synchronously after parsing the glTF properties
  76296. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76297. */
  76298. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76299. /**
  76300. * Define this method to modify the default behavior when loading cameras.
  76301. * @param context The context when loading the asset
  76302. * @param camera The glTF camera property
  76303. * @param assign A function called synchronously after parsing the glTF properties
  76304. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76305. */
  76306. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76307. /**
  76308. * @hidden
  76309. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76310. * @param context The context when loading the asset
  76311. * @param primitive The glTF mesh primitive property
  76312. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76313. */
  76314. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76315. /**
  76316. * @hidden
  76317. * Define this method to modify the default behavior when loading data for mesh primitives.
  76318. * @param context The context when loading the asset
  76319. * @param name The mesh name when loading the asset
  76320. * @param node The glTF node when loading the asset
  76321. * @param mesh The glTF mesh when loading the asset
  76322. * @param primitive The glTF mesh primitive property
  76323. * @param assign A function called synchronously after parsing the glTF properties
  76324. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76325. */
  76326. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76327. /**
  76328. * @hidden
  76329. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76330. * @param context The context when loading the asset
  76331. * @param material The glTF material property
  76332. * @param assign A function called synchronously after parsing the glTF properties
  76333. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76334. */
  76335. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76336. /**
  76337. * Define this method to modify the default behavior when creating materials.
  76338. * @param context The context when loading the asset
  76339. * @param material The glTF material property
  76340. * @param babylonDrawMode The draw mode for the Babylon material
  76341. * @returns The Babylon material or null if not handled
  76342. */
  76343. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76344. /**
  76345. * Define this method to modify the default behavior when loading material properties.
  76346. * @param context The context when loading the asset
  76347. * @param material The glTF material property
  76348. * @param babylonMaterial The Babylon material
  76349. * @returns A promise that resolves when the load is complete or null if not handled
  76350. */
  76351. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76352. /**
  76353. * Define this method to modify the default behavior when loading texture infos.
  76354. * @param context The context when loading the asset
  76355. * @param textureInfo The glTF texture info property
  76356. * @param assign A function called synchronously after parsing the glTF properties
  76357. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76358. */
  76359. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76360. /**
  76361. * @hidden
  76362. * Define this method to modify the default behavior when loading textures.
  76363. * @param context The context when loading the asset
  76364. * @param texture The glTF texture property
  76365. * @param assign A function called synchronously after parsing the glTF properties
  76366. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76367. */
  76368. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76369. /**
  76370. * Define this method to modify the default behavior when loading animations.
  76371. * @param context The context when loading the asset
  76372. * @param animation The glTF animation property
  76373. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76374. */
  76375. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76376. /**
  76377. * @hidden
  76378. * Define this method to modify the default behavior when loading skins.
  76379. * @param context The context when loading the asset
  76380. * @param node The glTF node property
  76381. * @param skin The glTF skin property
  76382. * @returns A promise that resolves when the load is complete or null if not handled
  76383. */
  76384. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76385. /**
  76386. * @hidden
  76387. * Define this method to modify the default behavior when loading uris.
  76388. * @param context The context when loading the asset
  76389. * @param property The glTF property associated with the uri
  76390. * @param uri The uri to load
  76391. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76392. */
  76393. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76394. /**
  76395. * Define this method to modify the default behavior when loading buffer views.
  76396. * @param context The context when loading the asset
  76397. * @param bufferView The glTF buffer view property
  76398. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76399. */
  76400. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76401. /**
  76402. * Define this method to modify the default behavior when loading buffers.
  76403. * @param context The context when loading the asset
  76404. * @param buffer The glTF buffer property
  76405. * @param byteOffset The byte offset to load
  76406. * @param byteLength The byte length to load
  76407. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76408. */
  76409. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76410. }
  76411. }
  76412. declare module BABYLON.GLTF2 {
  76413. /**
  76414. * Helper class for working with arrays when loading the glTF asset
  76415. */
  76416. export class ArrayItem {
  76417. /**
  76418. * Gets an item from the given array.
  76419. * @param context The context when loading the asset
  76420. * @param array The array to get the item from
  76421. * @param index The index to the array
  76422. * @returns The array item
  76423. */
  76424. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76425. /**
  76426. * Assign an `index` field to each item of the given array.
  76427. * @param array The array of items
  76428. */
  76429. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76430. }
  76431. /**
  76432. * The glTF 2.0 loader
  76433. */
  76434. export class GLTFLoader implements IGLTFLoader {
  76435. /** @hidden */
  76436. _completePromises: Promise<any>[];
  76437. /** @hidden */
  76438. _forAssetContainer: boolean;
  76439. /** Storage */
  76440. _babylonLights: Light[];
  76441. private _disposed;
  76442. private _parent;
  76443. private _state;
  76444. private _extensions;
  76445. private _rootUrl;
  76446. private _fileName;
  76447. private _uniqueRootUrl;
  76448. private _gltf;
  76449. private _bin;
  76450. private _babylonScene;
  76451. private _rootBabylonMesh;
  76452. private _defaultBabylonMaterialData;
  76453. private _progressCallback?;
  76454. private _requests;
  76455. private static _RegisteredExtensions;
  76456. /**
  76457. * The default glTF sampler.
  76458. */
  76459. static readonly DefaultSampler: ISampler;
  76460. /**
  76461. * Registers a loader extension.
  76462. * @param name The name of the loader extension.
  76463. * @param factory The factory function that creates the loader extension.
  76464. */
  76465. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76466. /**
  76467. * Unregisters a loader extension.
  76468. * @param name The name of the loader extension.
  76469. * @returns A boolean indicating whether the extension has been unregistered
  76470. */
  76471. static UnregisterExtension(name: string): boolean;
  76472. /**
  76473. * The loader state.
  76474. */
  76475. get state(): Nullable<GLTFLoaderState>;
  76476. /**
  76477. * The object that represents the glTF JSON.
  76478. */
  76479. get gltf(): IGLTF;
  76480. /**
  76481. * The BIN chunk of a binary glTF.
  76482. */
  76483. get bin(): Nullable<IDataBuffer>;
  76484. /**
  76485. * The parent file loader.
  76486. */
  76487. get parent(): GLTFFileLoader;
  76488. /**
  76489. * The Babylon scene when loading the asset.
  76490. */
  76491. get babylonScene(): Scene;
  76492. /**
  76493. * The root Babylon mesh when loading the asset.
  76494. */
  76495. get rootBabylonMesh(): Mesh;
  76496. /** @hidden */
  76497. constructor(parent: GLTFFileLoader);
  76498. /** @hidden */
  76499. dispose(): void;
  76500. /** @hidden */
  76501. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76502. /** @hidden */
  76503. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76504. private _loadAsync;
  76505. private _loadData;
  76506. private _setupData;
  76507. private _loadExtensions;
  76508. private _checkExtensions;
  76509. private _setState;
  76510. private _createRootNode;
  76511. /**
  76512. * Loads a glTF scene.
  76513. * @param context The context when loading the asset
  76514. * @param scene The glTF scene property
  76515. * @returns A promise that resolves when the load is complete
  76516. */
  76517. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76518. private _forEachPrimitive;
  76519. private _getMeshes;
  76520. private _getTransformNodes;
  76521. private _getSkeletons;
  76522. private _getAnimationGroups;
  76523. private _startAnimations;
  76524. /**
  76525. * Loads a glTF node.
  76526. * @param context The context when loading the asset
  76527. * @param node The glTF node property
  76528. * @param assign A function called synchronously after parsing the glTF properties
  76529. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76530. */
  76531. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76532. private _loadMeshAsync;
  76533. /**
  76534. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76535. * @param context The context when loading the asset
  76536. * @param name The mesh name when loading the asset
  76537. * @param node The glTF node when loading the asset
  76538. * @param mesh The glTF mesh when loading the asset
  76539. * @param primitive The glTF mesh primitive property
  76540. * @param assign A function called synchronously after parsing the glTF properties
  76541. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76542. */
  76543. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76544. private _loadVertexDataAsync;
  76545. private _createMorphTargets;
  76546. private _loadMorphTargetsAsync;
  76547. private _loadMorphTargetVertexDataAsync;
  76548. private static _LoadTransform;
  76549. private _loadSkinAsync;
  76550. private _loadBones;
  76551. private _loadBone;
  76552. private _loadSkinInverseBindMatricesDataAsync;
  76553. private _updateBoneMatrices;
  76554. private _getNodeMatrix;
  76555. /**
  76556. * Loads a glTF camera.
  76557. * @param context The context when loading the asset
  76558. * @param camera The glTF camera property
  76559. * @param assign A function called synchronously after parsing the glTF properties
  76560. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76561. */
  76562. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76563. private _loadAnimationsAsync;
  76564. /**
  76565. * Loads a glTF animation.
  76566. * @param context The context when loading the asset
  76567. * @param animation The glTF animation property
  76568. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76569. */
  76570. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76571. /**
  76572. * @hidden Loads a glTF animation channel.
  76573. * @param context The context when loading the asset
  76574. * @param animationContext The context of the animation when loading the asset
  76575. * @param animation The glTF animation property
  76576. * @param channel The glTF animation channel property
  76577. * @param babylonAnimationGroup The babylon animation group property
  76578. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76579. * @returns A void promise when the channel load is complete
  76580. */
  76581. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76582. private _loadAnimationSamplerAsync;
  76583. private _loadBufferAsync;
  76584. /**
  76585. * Loads a glTF buffer view.
  76586. * @param context The context when loading the asset
  76587. * @param bufferView The glTF buffer view property
  76588. * @returns A promise that resolves with the loaded data when the load is complete
  76589. */
  76590. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76591. private _loadAccessorAsync;
  76592. /** @hidden */
  76593. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76594. private _loadIndicesAccessorAsync;
  76595. private _loadVertexBufferViewAsync;
  76596. private _loadVertexAccessorAsync;
  76597. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76598. /** @hidden */
  76599. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76600. private _createDefaultMaterial;
  76601. /**
  76602. * Creates a Babylon material from a glTF material.
  76603. * @param context The context when loading the asset
  76604. * @param material The glTF material property
  76605. * @param babylonDrawMode The draw mode for the Babylon material
  76606. * @returns The Babylon material
  76607. */
  76608. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76609. /**
  76610. * Loads properties from a glTF material into a Babylon material.
  76611. * @param context The context when loading the asset
  76612. * @param material The glTF material property
  76613. * @param babylonMaterial The Babylon material
  76614. * @returns A promise that resolves when the load is complete
  76615. */
  76616. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76617. /**
  76618. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76619. * @param context The context when loading the asset
  76620. * @param material The glTF material property
  76621. * @param babylonMaterial The Babylon material
  76622. * @returns A promise that resolves when the load is complete
  76623. */
  76624. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76625. /**
  76626. * Loads the alpha properties from a glTF material into a Babylon material.
  76627. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76628. * @param context The context when loading the asset
  76629. * @param material The glTF material property
  76630. * @param babylonMaterial The Babylon material
  76631. */
  76632. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76633. /**
  76634. * Loads a glTF texture info.
  76635. * @param context The context when loading the asset
  76636. * @param textureInfo The glTF texture info property
  76637. * @param assign A function called synchronously after parsing the glTF properties
  76638. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76639. */
  76640. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76641. /** @hidden */
  76642. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76643. /** @hidden */
  76644. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76645. private _loadSampler;
  76646. /**
  76647. * Loads a glTF image.
  76648. * @param context The context when loading the asset
  76649. * @param image The glTF image property
  76650. * @returns A promise that resolves with the loaded data when the load is complete
  76651. */
  76652. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76653. /**
  76654. * Loads a glTF uri.
  76655. * @param context The context when loading the asset
  76656. * @param property The glTF property associated with the uri
  76657. * @param uri The base64 or relative uri
  76658. * @returns A promise that resolves with the loaded data when the load is complete
  76659. */
  76660. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76661. private _onProgress;
  76662. /**
  76663. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76664. * @param babylonObject the Babylon object with metadata
  76665. * @param pointer the JSON pointer
  76666. */
  76667. static AddPointerMetadata(babylonObject: {
  76668. metadata: any;
  76669. }, pointer: string): void;
  76670. private static _GetTextureWrapMode;
  76671. private static _GetTextureSamplingMode;
  76672. private static _GetTypedArrayConstructor;
  76673. private static _GetTypedArray;
  76674. private static _GetNumComponents;
  76675. private static _ValidateUri;
  76676. private static _GetDrawMode;
  76677. private _compileMaterialsAsync;
  76678. private _compileShadowGeneratorsAsync;
  76679. private _forEachExtensions;
  76680. private _applyExtensions;
  76681. private _extensionsOnLoading;
  76682. private _extensionsOnReady;
  76683. private _extensionsLoadSceneAsync;
  76684. private _extensionsLoadNodeAsync;
  76685. private _extensionsLoadCameraAsync;
  76686. private _extensionsLoadVertexDataAsync;
  76687. private _extensionsLoadMeshPrimitiveAsync;
  76688. private _extensionsLoadMaterialAsync;
  76689. private _extensionsCreateMaterial;
  76690. private _extensionsLoadMaterialPropertiesAsync;
  76691. private _extensionsLoadTextureInfoAsync;
  76692. private _extensionsLoadTextureAsync;
  76693. private _extensionsLoadAnimationAsync;
  76694. private _extensionsLoadSkinAsync;
  76695. private _extensionsLoadUriAsync;
  76696. private _extensionsLoadBufferViewAsync;
  76697. private _extensionsLoadBufferAsync;
  76698. /**
  76699. * Helper method called by a loader extension to load an glTF extension.
  76700. * @param context The context when loading the asset
  76701. * @param property The glTF property to load the extension from
  76702. * @param extensionName The name of the extension to load
  76703. * @param actionAsync The action to run
  76704. * @returns The promise returned by actionAsync or null if the extension does not exist
  76705. */
  76706. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76707. /**
  76708. * Helper method called by a loader extension to load a glTF extra.
  76709. * @param context The context when loading the asset
  76710. * @param property The glTF property to load the extra from
  76711. * @param extensionName The name of the extension to load
  76712. * @param actionAsync The action to run
  76713. * @returns The promise returned by actionAsync or null if the extra does not exist
  76714. */
  76715. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76716. /**
  76717. * Checks for presence of an extension.
  76718. * @param name The name of the extension to check
  76719. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76720. */
  76721. isExtensionUsed(name: string): boolean;
  76722. /**
  76723. * Increments the indentation level and logs a message.
  76724. * @param message The message to log
  76725. */
  76726. logOpen(message: string): void;
  76727. /**
  76728. * Decrements the indentation level.
  76729. */
  76730. logClose(): void;
  76731. /**
  76732. * Logs a message
  76733. * @param message The message to log
  76734. */
  76735. log(message: string): void;
  76736. /**
  76737. * Starts a performance counter.
  76738. * @param counterName The name of the performance counter
  76739. */
  76740. startPerformanceCounter(counterName: string): void;
  76741. /**
  76742. * Ends a performance counter.
  76743. * @param counterName The name of the performance counter
  76744. */
  76745. endPerformanceCounter(counterName: string): void;
  76746. }
  76747. }
  76748. declare module BABYLON.GLTF2.Loader.Extensions {
  76749. /**
  76750. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76751. */
  76752. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76753. /**
  76754. * The name of this extension.
  76755. */
  76756. readonly name: string;
  76757. /**
  76758. * Defines whether this extension is enabled.
  76759. */
  76760. enabled: boolean;
  76761. private _loader;
  76762. private _lights?;
  76763. /** @hidden */
  76764. constructor(loader: GLTFLoader);
  76765. /** @hidden */
  76766. dispose(): void;
  76767. /** @hidden */
  76768. onLoading(): void;
  76769. /** @hidden */
  76770. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76771. private _loadLightAsync;
  76772. }
  76773. }
  76774. declare module BABYLON.GLTF2.Loader.Extensions {
  76775. /**
  76776. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76777. */
  76778. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76779. /**
  76780. * The name of this extension.
  76781. */
  76782. readonly name: string;
  76783. /**
  76784. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76785. */
  76786. dracoCompression?: DracoCompression;
  76787. /**
  76788. * Defines whether this extension is enabled.
  76789. */
  76790. enabled: boolean;
  76791. private _loader;
  76792. /** @hidden */
  76793. constructor(loader: GLTFLoader);
  76794. /** @hidden */
  76795. dispose(): void;
  76796. /** @hidden */
  76797. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76798. }
  76799. }
  76800. declare module BABYLON.GLTF2.Loader.Extensions {
  76801. /**
  76802. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76803. */
  76804. export class KHR_lights implements IGLTFLoaderExtension {
  76805. /**
  76806. * The name of this extension.
  76807. */
  76808. readonly name: string;
  76809. /**
  76810. * Defines whether this extension is enabled.
  76811. */
  76812. enabled: boolean;
  76813. private _loader;
  76814. private _lights?;
  76815. /** @hidden */
  76816. constructor(loader: GLTFLoader);
  76817. /** @hidden */
  76818. dispose(): void;
  76819. /** @hidden */
  76820. onLoading(): void;
  76821. /** @hidden */
  76822. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76823. }
  76824. }
  76825. declare module BABYLON.GLTF2.Loader.Extensions {
  76826. /**
  76827. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76828. */
  76829. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76830. /**
  76831. * The name of this extension.
  76832. */
  76833. readonly name: string;
  76834. /**
  76835. * Defines whether this extension is enabled.
  76836. */
  76837. enabled: boolean;
  76838. /**
  76839. * Defines a number that determines the order the extensions are applied.
  76840. */
  76841. order: number;
  76842. private _loader;
  76843. /** @hidden */
  76844. constructor(loader: GLTFLoader);
  76845. /** @hidden */
  76846. dispose(): void;
  76847. /** @hidden */
  76848. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76849. private _loadSpecularGlossinessPropertiesAsync;
  76850. }
  76851. }
  76852. declare module BABYLON.GLTF2.Loader.Extensions {
  76853. /**
  76854. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76855. */
  76856. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76857. /**
  76858. * The name of this extension.
  76859. */
  76860. readonly name: string;
  76861. /**
  76862. * Defines whether this extension is enabled.
  76863. */
  76864. enabled: boolean;
  76865. /**
  76866. * Defines a number that determines the order the extensions are applied.
  76867. */
  76868. order: number;
  76869. private _loader;
  76870. /** @hidden */
  76871. constructor(loader: GLTFLoader);
  76872. /** @hidden */
  76873. dispose(): void;
  76874. /** @hidden */
  76875. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76876. private _loadUnlitPropertiesAsync;
  76877. }
  76878. }
  76879. declare module BABYLON.GLTF2.Loader.Extensions {
  76880. /**
  76881. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76882. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76883. * !!! Experimental Extension Subject to Changes !!!
  76884. */
  76885. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76886. /**
  76887. * The name of this extension.
  76888. */
  76889. readonly name: string;
  76890. /**
  76891. * Defines whether this extension is enabled.
  76892. */
  76893. enabled: boolean;
  76894. /**
  76895. * Defines a number that determines the order the extensions are applied.
  76896. */
  76897. order: number;
  76898. private _loader;
  76899. /** @hidden */
  76900. constructor(loader: GLTFLoader);
  76901. /** @hidden */
  76902. dispose(): void;
  76903. /** @hidden */
  76904. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76905. private _loadClearCoatPropertiesAsync;
  76906. }
  76907. }
  76908. declare module BABYLON.GLTF2.Loader.Extensions {
  76909. /**
  76910. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76911. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76912. * !!! Experimental Extension Subject to Changes !!!
  76913. */
  76914. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76915. /**
  76916. * The name of this extension.
  76917. */
  76918. readonly name: string;
  76919. /**
  76920. * Defines whether this extension is enabled.
  76921. */
  76922. enabled: boolean;
  76923. /**
  76924. * Defines a number that determines the order the extensions are applied.
  76925. */
  76926. order: number;
  76927. private _loader;
  76928. /** @hidden */
  76929. constructor(loader: GLTFLoader);
  76930. /** @hidden */
  76931. dispose(): void;
  76932. /** @hidden */
  76933. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76934. private _loadSheenPropertiesAsync;
  76935. }
  76936. }
  76937. declare module BABYLON.GLTF2.Loader.Extensions {
  76938. /**
  76939. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76940. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76941. * !!! Experimental Extension Subject to Changes !!!
  76942. */
  76943. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76944. /**
  76945. * The name of this extension.
  76946. */
  76947. readonly name: string;
  76948. /**
  76949. * Defines whether this extension is enabled.
  76950. */
  76951. enabled: boolean;
  76952. /**
  76953. * Defines a number that determines the order the extensions are applied.
  76954. */
  76955. order: number;
  76956. private _loader;
  76957. /** @hidden */
  76958. constructor(loader: GLTFLoader);
  76959. /** @hidden */
  76960. dispose(): void;
  76961. /** @hidden */
  76962. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76963. private _loadSpecularPropertiesAsync;
  76964. }
  76965. }
  76966. declare module BABYLON.GLTF2.Loader.Extensions {
  76967. /**
  76968. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76969. * [Playground Sample](//TODO)
  76970. * !!! Experimental Extension Subject to Changes !!!
  76971. */
  76972. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76973. /**
  76974. * The name of this extension.
  76975. */
  76976. readonly name: string;
  76977. /**
  76978. * Defines whether this extension is enabled.
  76979. */
  76980. enabled: boolean;
  76981. private _loader;
  76982. /** @hidden */
  76983. constructor(loader: GLTFLoader);
  76984. /** @hidden */
  76985. dispose(): void;
  76986. /** @hidden */
  76987. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76988. }
  76989. }
  76990. declare module BABYLON.GLTF2.Loader.Extensions {
  76991. /**
  76992. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76993. */
  76994. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76995. /**
  76996. * The name of this extension.
  76997. */
  76998. readonly name: string;
  76999. /**
  77000. * Defines whether this extension is enabled.
  77001. */
  77002. enabled: boolean;
  77003. /** @hidden */
  77004. constructor(loader: GLTFLoader);
  77005. /** @hidden */
  77006. dispose(): void;
  77007. }
  77008. }
  77009. declare module BABYLON.GLTF2.Loader.Extensions {
  77010. /**
  77011. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77012. * !!! Experimental Extension Subject to Changes !!!
  77013. */
  77014. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77015. /** The name of this extension. */
  77016. readonly name: string;
  77017. /** Defines whether this extension is enabled. */
  77018. enabled: boolean;
  77019. private _loader;
  77020. /** @hidden */
  77021. constructor(loader: GLTFLoader);
  77022. /** @hidden */
  77023. dispose(): void;
  77024. /** @hidden */
  77025. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77026. }
  77027. }
  77028. declare module BABYLON.GLTF2.Loader.Extensions {
  77029. /**
  77030. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77031. */
  77032. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77033. /**
  77034. * The name of this extension.
  77035. */
  77036. readonly name: string;
  77037. /**
  77038. * Defines whether this extension is enabled.
  77039. */
  77040. enabled: boolean;
  77041. private _loader;
  77042. /** @hidden */
  77043. constructor(loader: GLTFLoader);
  77044. /** @hidden */
  77045. dispose(): void;
  77046. /** @hidden */
  77047. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77048. }
  77049. }
  77050. declare module BABYLON.GLTF2.Loader.Extensions {
  77051. /**
  77052. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77053. */
  77054. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77055. /**
  77056. * The name of this extension.
  77057. */
  77058. readonly name: string;
  77059. /**
  77060. * Defines whether this extension is enabled.
  77061. */
  77062. enabled: boolean;
  77063. private _loader;
  77064. private _clips;
  77065. private _emitters;
  77066. /** @hidden */
  77067. constructor(loader: GLTFLoader);
  77068. /** @hidden */
  77069. dispose(): void;
  77070. /** @hidden */
  77071. onLoading(): void;
  77072. /** @hidden */
  77073. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77074. /** @hidden */
  77075. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77076. /** @hidden */
  77077. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77078. private _loadClipAsync;
  77079. private _loadEmitterAsync;
  77080. private _getEventAction;
  77081. private _loadAnimationEventAsync;
  77082. }
  77083. }
  77084. declare module BABYLON.GLTF2.Loader.Extensions {
  77085. /**
  77086. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77087. */
  77088. export class MSFT_lod implements IGLTFLoaderExtension {
  77089. /**
  77090. * The name of this extension.
  77091. */
  77092. readonly name: string;
  77093. /**
  77094. * Defines whether this extension is enabled.
  77095. */
  77096. enabled: boolean;
  77097. /**
  77098. * Defines a number that determines the order the extensions are applied.
  77099. */
  77100. order: number;
  77101. /**
  77102. * Maximum number of LODs to load, starting from the lowest LOD.
  77103. */
  77104. maxLODsToLoad: number;
  77105. /**
  77106. * Observable raised when all node LODs of one level are loaded.
  77107. * The event data is the index of the loaded LOD starting from zero.
  77108. * Dispose the loader to cancel the loading of the next level of LODs.
  77109. */
  77110. onNodeLODsLoadedObservable: Observable<number>;
  77111. /**
  77112. * Observable raised when all material LODs of one level are loaded.
  77113. * The event data is the index of the loaded LOD starting from zero.
  77114. * Dispose the loader to cancel the loading of the next level of LODs.
  77115. */
  77116. onMaterialLODsLoadedObservable: Observable<number>;
  77117. private _loader;
  77118. private _nodeIndexLOD;
  77119. private _nodeSignalLODs;
  77120. private _nodePromiseLODs;
  77121. private _materialIndexLOD;
  77122. private _materialSignalLODs;
  77123. private _materialPromiseLODs;
  77124. private _indexLOD;
  77125. private _bufferLODs;
  77126. /** @hidden */
  77127. constructor(loader: GLTFLoader);
  77128. /** @hidden */
  77129. dispose(): void;
  77130. /** @hidden */
  77131. onReady(): void;
  77132. /** @hidden */
  77133. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77134. /** @hidden */
  77135. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77136. /** @hidden */
  77137. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77138. /** @hidden */
  77139. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77140. /** @hidden */
  77141. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77142. private _loadBufferLOD;
  77143. /**
  77144. * Gets an array of LOD properties from lowest to highest.
  77145. */
  77146. private _getLODs;
  77147. private _disposeTransformNode;
  77148. private _disposeMaterials;
  77149. }
  77150. }
  77151. declare module BABYLON.GLTF2.Loader.Extensions {
  77152. /** @hidden */
  77153. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77154. readonly name: string;
  77155. enabled: boolean;
  77156. private _loader;
  77157. constructor(loader: GLTFLoader);
  77158. dispose(): void;
  77159. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77160. }
  77161. }
  77162. declare module BABYLON.GLTF2.Loader.Extensions {
  77163. /** @hidden */
  77164. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77165. readonly name: string;
  77166. enabled: boolean;
  77167. private _loader;
  77168. constructor(loader: GLTFLoader);
  77169. dispose(): void;
  77170. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77171. }
  77172. }
  77173. declare module BABYLON.GLTF2.Loader.Extensions {
  77174. /**
  77175. * Store glTF extras (if present) in BJS objects' metadata
  77176. */
  77177. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77178. /**
  77179. * The name of this extension.
  77180. */
  77181. readonly name: string;
  77182. /**
  77183. * Defines whether this extension is enabled.
  77184. */
  77185. enabled: boolean;
  77186. private _loader;
  77187. private _assignExtras;
  77188. /** @hidden */
  77189. constructor(loader: GLTFLoader);
  77190. /** @hidden */
  77191. dispose(): void;
  77192. /** @hidden */
  77193. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77194. /** @hidden */
  77195. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77196. /** @hidden */
  77197. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77198. }
  77199. }
  77200. declare module BABYLON {
  77201. /**
  77202. * Class reading and parsing the MTL file bundled with the obj file.
  77203. */
  77204. export class MTLFileLoader {
  77205. /**
  77206. * Invert Y-Axis of referenced textures on load
  77207. */
  77208. static INVERT_TEXTURE_Y: boolean;
  77209. /**
  77210. * All material loaded from the mtl will be set here
  77211. */
  77212. materials: StandardMaterial[];
  77213. /**
  77214. * This function will read the mtl file and create each material described inside
  77215. * This function could be improve by adding :
  77216. * -some component missing (Ni, Tf...)
  77217. * -including the specific options available
  77218. *
  77219. * @param scene defines the scene the material will be created in
  77220. * @param data defines the mtl data to parse
  77221. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77222. * @param forAssetContainer defines if the material should be registered in the scene
  77223. */
  77224. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77225. /**
  77226. * Gets the texture for the material.
  77227. *
  77228. * If the material is imported from input file,
  77229. * We sanitize the url to ensure it takes the textre from aside the material.
  77230. *
  77231. * @param rootUrl The root url to load from
  77232. * @param value The value stored in the mtl
  77233. * @return The Texture
  77234. */
  77235. private static _getTexture;
  77236. }
  77237. }
  77238. declare module BABYLON {
  77239. /**
  77240. * Options for loading OBJ/MTL files
  77241. */
  77242. type MeshLoadOptions = {
  77243. /**
  77244. * Defines if UVs are optimized by default during load.
  77245. */
  77246. OptimizeWithUV: boolean;
  77247. /**
  77248. * Defines custom scaling of UV coordinates of loaded meshes.
  77249. */
  77250. UVScaling: Vector2;
  77251. /**
  77252. * Invert model on y-axis (does a model scaling inversion)
  77253. */
  77254. InvertY: boolean;
  77255. /**
  77256. * Invert Y-Axis of referenced textures on load
  77257. */
  77258. InvertTextureY: boolean;
  77259. /**
  77260. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77261. */
  77262. ImportVertexColors: boolean;
  77263. /**
  77264. * Compute the normals for the model, even if normals are present in the file.
  77265. */
  77266. ComputeNormals: boolean;
  77267. /**
  77268. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77269. */
  77270. SkipMaterials: boolean;
  77271. /**
  77272. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77273. */
  77274. MaterialLoadingFailsSilently: boolean;
  77275. };
  77276. /**
  77277. * OBJ file type loader.
  77278. * This is a babylon scene loader plugin.
  77279. */
  77280. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77281. /**
  77282. * Defines if UVs are optimized by default during load.
  77283. */
  77284. static OPTIMIZE_WITH_UV: boolean;
  77285. /**
  77286. * Invert model on y-axis (does a model scaling inversion)
  77287. */
  77288. static INVERT_Y: boolean;
  77289. /**
  77290. * Invert Y-Axis of referenced textures on load
  77291. */
  77292. static get INVERT_TEXTURE_Y(): boolean;
  77293. static set INVERT_TEXTURE_Y(value: boolean);
  77294. /**
  77295. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77296. */
  77297. static IMPORT_VERTEX_COLORS: boolean;
  77298. /**
  77299. * Compute the normals for the model, even if normals are present in the file.
  77300. */
  77301. static COMPUTE_NORMALS: boolean;
  77302. /**
  77303. * Defines custom scaling of UV coordinates of loaded meshes.
  77304. */
  77305. static UV_SCALING: Vector2;
  77306. /**
  77307. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77308. */
  77309. static SKIP_MATERIALS: boolean;
  77310. /**
  77311. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77312. *
  77313. * Defaults to true for backwards compatibility.
  77314. */
  77315. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77316. /**
  77317. * Defines the name of the plugin.
  77318. */
  77319. name: string;
  77320. /**
  77321. * Defines the extension the plugin is able to load.
  77322. */
  77323. extensions: string;
  77324. /** @hidden */
  77325. obj: RegExp;
  77326. /** @hidden */
  77327. group: RegExp;
  77328. /** @hidden */
  77329. mtllib: RegExp;
  77330. /** @hidden */
  77331. usemtl: RegExp;
  77332. /** @hidden */
  77333. smooth: RegExp;
  77334. /** @hidden */
  77335. vertexPattern: RegExp;
  77336. /** @hidden */
  77337. normalPattern: RegExp;
  77338. /** @hidden */
  77339. uvPattern: RegExp;
  77340. /** @hidden */
  77341. facePattern1: RegExp;
  77342. /** @hidden */
  77343. facePattern2: RegExp;
  77344. /** @hidden */
  77345. facePattern3: RegExp;
  77346. /** @hidden */
  77347. facePattern4: RegExp;
  77348. /** @hidden */
  77349. facePattern5: RegExp;
  77350. private _forAssetContainer;
  77351. private _meshLoadOptions;
  77352. /**
  77353. * Creates loader for .OBJ files
  77354. *
  77355. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77356. */
  77357. constructor(meshLoadOptions?: MeshLoadOptions);
  77358. private static get currentMeshLoadOptions();
  77359. /**
  77360. * Calls synchronously the MTL file attached to this obj.
  77361. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77362. * Without this function materials are not displayed in the first frame (but displayed after).
  77363. * In consequence it is impossible to get material information in your HTML file
  77364. *
  77365. * @param url The URL of the MTL file
  77366. * @param rootUrl
  77367. * @param onSuccess Callback function to be called when the MTL file is loaded
  77368. * @private
  77369. */
  77370. private _loadMTL;
  77371. /**
  77372. * Instantiates a OBJ file loader plugin.
  77373. * @returns the created plugin
  77374. */
  77375. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77376. /**
  77377. * If the data string can be loaded directly.
  77378. *
  77379. * @param data string containing the file data
  77380. * @returns if the data can be loaded directly
  77381. */
  77382. canDirectLoad(data: string): boolean;
  77383. /**
  77384. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77385. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77386. * @param scene the scene the meshes should be added to
  77387. * @param data the OBJ data to load
  77388. * @param rootUrl root url to load from
  77389. * @param onProgress event that fires when loading progress has occured
  77390. * @param fileName Defines the name of the file to load
  77391. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77392. */
  77393. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77394. meshes: AbstractMesh[];
  77395. particleSystems: IParticleSystem[];
  77396. skeletons: Skeleton[];
  77397. animationGroups: AnimationGroup[];
  77398. }>;
  77399. /**
  77400. * Imports all objects from the loaded OBJ data and adds them to the scene
  77401. * @param scene the scene the objects should be added to
  77402. * @param data the OBJ data to load
  77403. * @param rootUrl root url to load from
  77404. * @param onProgress event that fires when loading progress has occured
  77405. * @param fileName Defines the name of the file to load
  77406. * @returns a promise which completes when objects have been loaded to the scene
  77407. */
  77408. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77409. /**
  77410. * Load into an asset container.
  77411. * @param scene The scene to load into
  77412. * @param data The data to import
  77413. * @param rootUrl The root url for scene and resources
  77414. * @param onProgress The callback when the load progresses
  77415. * @param fileName Defines the name of the file to load
  77416. * @returns The loaded asset container
  77417. */
  77418. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77419. /**
  77420. * Read the OBJ file and create an Array of meshes.
  77421. * Each mesh contains all information given by the OBJ and the MTL file.
  77422. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77423. *
  77424. * @param meshesNames
  77425. * @param scene Scene The scene where are displayed the data
  77426. * @param data String The content of the obj file
  77427. * @param rootUrl String The path to the folder
  77428. * @returns Array<AbstractMesh>
  77429. * @private
  77430. */
  77431. private _parseSolid;
  77432. }
  77433. }
  77434. declare module BABYLON {
  77435. /**
  77436. * STL file type loader.
  77437. * This is a babylon scene loader plugin.
  77438. */
  77439. export class STLFileLoader implements ISceneLoaderPlugin {
  77440. /** @hidden */
  77441. solidPattern: RegExp;
  77442. /** @hidden */
  77443. facetsPattern: RegExp;
  77444. /** @hidden */
  77445. normalPattern: RegExp;
  77446. /** @hidden */
  77447. vertexPattern: RegExp;
  77448. /**
  77449. * Defines the name of the plugin.
  77450. */
  77451. name: string;
  77452. /**
  77453. * Defines the extensions the stl loader is able to load.
  77454. * force data to come in as an ArrayBuffer
  77455. * we'll convert to string if it looks like it's an ASCII .stl
  77456. */
  77457. extensions: ISceneLoaderPluginExtensions;
  77458. /**
  77459. * Import meshes into a scene.
  77460. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77461. * @param scene The scene to import into
  77462. * @param data The data to import
  77463. * @param rootUrl The root url for scene and resources
  77464. * @param meshes The meshes array to import into
  77465. * @param particleSystems The particle systems array to import into
  77466. * @param skeletons The skeletons array to import into
  77467. * @param onError The callback when import fails
  77468. * @returns True if successful or false otherwise
  77469. */
  77470. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77471. /**
  77472. * Load into a scene.
  77473. * @param scene The scene to load into
  77474. * @param data The data to import
  77475. * @param rootUrl The root url for scene and resources
  77476. * @param onError The callback when import fails
  77477. * @returns true if successful or false otherwise
  77478. */
  77479. load(scene: Scene, data: any, rootUrl: string): boolean;
  77480. /**
  77481. * Load into an asset container.
  77482. * @param scene The scene to load into
  77483. * @param data The data to import
  77484. * @param rootUrl The root url for scene and resources
  77485. * @param onError The callback when import fails
  77486. * @returns The loaded asset container
  77487. */
  77488. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77489. private _isBinary;
  77490. private _parseBinary;
  77491. private _parseASCII;
  77492. }
  77493. }
  77494. declare module BABYLON {
  77495. /**
  77496. * Class for generating OBJ data from a Babylon scene.
  77497. */
  77498. export class OBJExport {
  77499. /**
  77500. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77501. * @param mesh defines the list of meshes to serialize
  77502. * @param materials defines if materials should be exported
  77503. * @param matlibname defines the name of the associated mtl file
  77504. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77505. * @returns the OBJ content
  77506. */
  77507. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77508. /**
  77509. * Exports the material(s) of a mesh in .MTL file format (text)
  77510. * @param mesh defines the mesh to extract the material from
  77511. * @returns the mtl content
  77512. */
  77513. static MTL(mesh: Mesh): string;
  77514. }
  77515. }
  77516. declare module BABYLON {
  77517. /** @hidden */
  77518. export var __IGLTFExporterExtension: number;
  77519. /**
  77520. * Interface for extending the exporter
  77521. * @hidden
  77522. */
  77523. export interface IGLTFExporterExtension {
  77524. /**
  77525. * The name of this extension
  77526. */
  77527. readonly name: string;
  77528. /**
  77529. * Defines whether this extension is enabled
  77530. */
  77531. enabled: boolean;
  77532. /**
  77533. * Defines whether this extension is required
  77534. */
  77535. required: boolean;
  77536. }
  77537. }
  77538. declare module BABYLON.GLTF2.Exporter {
  77539. /** @hidden */
  77540. export var __IGLTFExporterExtensionV2: number;
  77541. /**
  77542. * Interface for a glTF exporter extension
  77543. * @hidden
  77544. */
  77545. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77546. /**
  77547. * Define this method to modify the default behavior before exporting a texture
  77548. * @param context The context when loading the asset
  77549. * @param babylonTexture The Babylon.js texture
  77550. * @param mimeType The mime-type of the generated image
  77551. * @returns A promise that resolves with the exported texture
  77552. */
  77553. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77554. /**
  77555. * Define this method to get notified when a texture info is created
  77556. * @param context The context when loading the asset
  77557. * @param textureInfo The glTF texture info
  77558. * @param babylonTexture The Babylon.js texture
  77559. */
  77560. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77561. /**
  77562. * Define this method to modify the default behavior when exporting texture info
  77563. * @param context The context when loading the asset
  77564. * @param meshPrimitive glTF mesh primitive
  77565. * @param babylonSubMesh Babylon submesh
  77566. * @param binaryWriter glTF serializer binary writer instance
  77567. * @returns nullable IMeshPrimitive promise
  77568. */
  77569. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77570. /**
  77571. * Define this method to modify the default behavior when exporting a node
  77572. * @param context The context when exporting the node
  77573. * @param node glTF node
  77574. * @param babylonNode BabylonJS node
  77575. * @returns nullable INode promise
  77576. */
  77577. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77578. [key: number]: number;
  77579. }): Promise<Nullable<INode>>;
  77580. /**
  77581. * Define this method to modify the default behavior when exporting a material
  77582. * @param material glTF material
  77583. * @param babylonMaterial BabylonJS material
  77584. * @returns nullable IMaterial promise
  77585. */
  77586. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77587. /**
  77588. * Define this method to return additional textures to export from a material
  77589. * @param material glTF material
  77590. * @param babylonMaterial BabylonJS material
  77591. * @returns List of textures
  77592. */
  77593. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77594. /** Gets a boolean indicating that this extension was used */
  77595. wasUsed: boolean;
  77596. /** Gets a boolean indicating that this extension is required for the file to work */
  77597. required: boolean;
  77598. /**
  77599. * Called after the exporter state changes to EXPORTING
  77600. */
  77601. onExporting?(): void;
  77602. }
  77603. }
  77604. declare module BABYLON.GLTF2.Exporter {
  77605. /**
  77606. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77607. * @hidden
  77608. */
  77609. export class _GLTFMaterialExporter {
  77610. /**
  77611. * Represents the dielectric specular values for R, G and B
  77612. */
  77613. private static readonly _DielectricSpecular;
  77614. /**
  77615. * Allows the maximum specular power to be defined for material calculations
  77616. */
  77617. private static readonly _MaxSpecularPower;
  77618. /**
  77619. * Mapping to store textures
  77620. */
  77621. private _textureMap;
  77622. /**
  77623. * Numeric tolerance value
  77624. */
  77625. private static readonly _Epsilon;
  77626. /**
  77627. * Reference to the glTF Exporter
  77628. */
  77629. private _exporter;
  77630. constructor(exporter: _Exporter);
  77631. /**
  77632. * Specifies if two colors are approximately equal in value
  77633. * @param color1 first color to compare to
  77634. * @param color2 second color to compare to
  77635. * @param epsilon threshold value
  77636. */
  77637. private static FuzzyEquals;
  77638. /**
  77639. * Gets the materials from a Babylon scene and converts them to glTF materials
  77640. * @param scene babylonjs scene
  77641. * @param mimeType texture mime type
  77642. * @param images array of images
  77643. * @param textures array of textures
  77644. * @param materials array of materials
  77645. * @param imageData mapping of texture names to base64 textures
  77646. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77647. */
  77648. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77649. /**
  77650. * Makes a copy of the glTF material without the texture parameters
  77651. * @param originalMaterial original glTF material
  77652. * @returns glTF material without texture parameters
  77653. */
  77654. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77655. /**
  77656. * Specifies if the material has any texture parameters present
  77657. * @param material glTF Material
  77658. * @returns boolean specifying if texture parameters are present
  77659. */
  77660. _hasTexturesPresent(material: IMaterial): boolean;
  77661. /**
  77662. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77663. * @param babylonStandardMaterial
  77664. * @returns glTF Metallic Roughness Material representation
  77665. */
  77666. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77667. /**
  77668. * Computes the metallic factor
  77669. * @param diffuse diffused value
  77670. * @param specular specular value
  77671. * @param oneMinusSpecularStrength one minus the specular strength
  77672. * @returns metallic value
  77673. */
  77674. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77675. /**
  77676. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77677. * @param glTFMaterial glTF material
  77678. * @param babylonMaterial Babylon material
  77679. */
  77680. private static _SetAlphaMode;
  77681. /**
  77682. * Converts a Babylon Standard Material to a glTF Material
  77683. * @param babylonStandardMaterial BJS Standard Material
  77684. * @param mimeType mime type to use for the textures
  77685. * @param images array of glTF image interfaces
  77686. * @param textures array of glTF texture interfaces
  77687. * @param materials array of glTF material interfaces
  77688. * @param imageData map of image file name to data
  77689. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77690. */
  77691. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77692. private _finishMaterial;
  77693. /**
  77694. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77695. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77696. * @param mimeType mime type to use for the textures
  77697. * @param images array of glTF image interfaces
  77698. * @param textures array of glTF texture interfaces
  77699. * @param materials array of glTF material interfaces
  77700. * @param imageData map of image file name to data
  77701. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77702. */
  77703. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77704. /**
  77705. * Converts an image typed array buffer to a base64 image
  77706. * @param buffer typed array buffer
  77707. * @param width width of the image
  77708. * @param height height of the image
  77709. * @param mimeType mimetype of the image
  77710. * @returns base64 image string
  77711. */
  77712. private _createBase64FromCanvasAsync;
  77713. /**
  77714. * Generates a white texture based on the specified width and height
  77715. * @param width width of the texture in pixels
  77716. * @param height height of the texture in pixels
  77717. * @param scene babylonjs scene
  77718. * @returns white texture
  77719. */
  77720. private _createWhiteTexture;
  77721. /**
  77722. * 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
  77723. * @param texture1 first texture to resize
  77724. * @param texture2 second texture to resize
  77725. * @param scene babylonjs scene
  77726. * @returns resized textures or null
  77727. */
  77728. private _resizeTexturesToSameDimensions;
  77729. /**
  77730. * Converts an array of pixels to a Float32Array
  77731. * Throws an error if the pixel format is not supported
  77732. * @param pixels - array buffer containing pixel values
  77733. * @returns Float32 of pixels
  77734. */
  77735. private _convertPixelArrayToFloat32;
  77736. /**
  77737. * Convert Specular Glossiness Textures to Metallic Roughness
  77738. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77739. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77740. * @param diffuseTexture texture used to store diffuse information
  77741. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77742. * @param factors specular glossiness material factors
  77743. * @param mimeType the mime type to use for the texture
  77744. * @returns pbr metallic roughness interface or null
  77745. */
  77746. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77747. /**
  77748. * Converts specular glossiness material properties to metallic roughness
  77749. * @param specularGlossiness interface with specular glossiness material properties
  77750. * @returns interface with metallic roughness material properties
  77751. */
  77752. private _convertSpecularGlossinessToMetallicRoughness;
  77753. /**
  77754. * Calculates the surface reflectance, independent of lighting conditions
  77755. * @param color Color source to calculate brightness from
  77756. * @returns number representing the perceived brightness, or zero if color is undefined
  77757. */
  77758. private _getPerceivedBrightness;
  77759. /**
  77760. * Returns the maximum color component value
  77761. * @param color
  77762. * @returns maximum color component value, or zero if color is null or undefined
  77763. */
  77764. private _getMaxComponent;
  77765. /**
  77766. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77767. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77768. * @param mimeType mime type to use for the textures
  77769. * @param images array of glTF image interfaces
  77770. * @param textures array of glTF texture interfaces
  77771. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77772. * @param imageData map of image file name to data
  77773. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77774. * @returns glTF PBR Metallic Roughness factors
  77775. */
  77776. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77777. private _getGLTFTextureSampler;
  77778. private _getGLTFTextureWrapMode;
  77779. private _getGLTFTextureWrapModesSampler;
  77780. /**
  77781. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77782. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77783. * @param mimeType mime type to use for the textures
  77784. * @param images array of glTF image interfaces
  77785. * @param textures array of glTF texture interfaces
  77786. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77787. * @param imageData map of image file name to data
  77788. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77789. * @returns glTF PBR Metallic Roughness factors
  77790. */
  77791. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77792. /**
  77793. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77794. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77795. * @param mimeType mime type to use for the textures
  77796. * @param images array of glTF image interfaces
  77797. * @param textures array of glTF texture interfaces
  77798. * @param materials array of glTF material interfaces
  77799. * @param imageData map of image file name to data
  77800. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77801. */
  77802. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77803. private setMetallicRoughnessPbrMaterial;
  77804. private getPixelsFromTexture;
  77805. /**
  77806. * Extracts a texture from a Babylon texture into file data and glTF data
  77807. * @param babylonTexture Babylon texture to extract
  77808. * @param mimeType Mime Type of the babylonTexture
  77809. * @return glTF texture info, or null if the texture format is not supported
  77810. */
  77811. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77812. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77813. /**
  77814. * Builds a texture from base64 string
  77815. * @param base64Texture base64 texture string
  77816. * @param baseTextureName Name to use for the texture
  77817. * @param mimeType image mime type for the texture
  77818. * @param images array of images
  77819. * @param textures array of textures
  77820. * @param imageData map of image data
  77821. * @returns glTF texture info, or null if the texture format is not supported
  77822. */
  77823. private _getTextureInfoFromBase64;
  77824. }
  77825. }
  77826. declare module BABYLON {
  77827. /**
  77828. * Class for holding and downloading glTF file data
  77829. */
  77830. export class GLTFData {
  77831. /**
  77832. * Object which contains the file name as the key and its data as the value
  77833. */
  77834. glTFFiles: {
  77835. [fileName: string]: string | Blob;
  77836. };
  77837. /**
  77838. * Initializes the glTF file object
  77839. */
  77840. constructor();
  77841. /**
  77842. * Downloads the glTF data as files based on their names and data
  77843. */
  77844. downloadFiles(): void;
  77845. }
  77846. }
  77847. declare module BABYLON {
  77848. /**
  77849. * Holds a collection of exporter options and parameters
  77850. */
  77851. export interface IExportOptions {
  77852. /**
  77853. * Function which indicates whether a babylon node should be exported or not
  77854. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77855. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77856. */
  77857. shouldExportNode?(node: Node): boolean;
  77858. /**
  77859. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77860. * @param metadata source metadata to read from
  77861. * @returns the data to store to glTF node extras
  77862. */
  77863. metadataSelector?(metadata: any): any;
  77864. /**
  77865. * The sample rate to bake animation curves
  77866. */
  77867. animationSampleRate?: number;
  77868. /**
  77869. * Begin serialization without waiting for the scene to be ready
  77870. */
  77871. exportWithoutWaitingForScene?: boolean;
  77872. /**
  77873. * Indicates if coordinate system swapping root nodes should be included in export
  77874. */
  77875. includeCoordinateSystemConversionNodes?: boolean;
  77876. }
  77877. /**
  77878. * Class for generating glTF data from a Babylon scene.
  77879. */
  77880. export class GLTF2Export {
  77881. /**
  77882. * Exports the geometry of the scene to .gltf file format asynchronously
  77883. * @param scene Babylon scene with scene hierarchy information
  77884. * @param filePrefix File prefix to use when generating the glTF file
  77885. * @param options Exporter options
  77886. * @returns Returns an object with a .gltf file and associates texture names
  77887. * as keys and their data and paths as values
  77888. */
  77889. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77890. private static _PreExportAsync;
  77891. private static _PostExportAsync;
  77892. /**
  77893. * Exports the geometry of the scene to .glb file format asychronously
  77894. * @param scene Babylon scene with scene hierarchy information
  77895. * @param filePrefix File prefix to use when generating glb file
  77896. * @param options Exporter options
  77897. * @returns Returns an object with a .glb filename as key and data as value
  77898. */
  77899. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77900. }
  77901. }
  77902. declare module BABYLON.GLTF2.Exporter {
  77903. /**
  77904. * @hidden
  77905. */
  77906. export class _GLTFUtilities {
  77907. /**
  77908. * Creates a buffer view based on the supplied arguments
  77909. * @param bufferIndex index value of the specified buffer
  77910. * @param byteOffset byte offset value
  77911. * @param byteLength byte length of the bufferView
  77912. * @param byteStride byte distance between conequential elements
  77913. * @param name name of the buffer view
  77914. * @returns bufferView for glTF
  77915. */
  77916. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77917. /**
  77918. * Creates an accessor based on the supplied arguments
  77919. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77920. * @param name The name of the accessor
  77921. * @param type The type of the accessor
  77922. * @param componentType The datatype of components in the attribute
  77923. * @param count The number of attributes referenced by this accessor
  77924. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77925. * @param min Minimum value of each component in this attribute
  77926. * @param max Maximum value of each component in this attribute
  77927. * @returns accessor for glTF
  77928. */
  77929. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77930. /**
  77931. * Calculates the minimum and maximum values of an array of position floats
  77932. * @param positions Positions array of a mesh
  77933. * @param vertexStart Starting vertex offset to calculate min and max values
  77934. * @param vertexCount Number of vertices to check for min and max values
  77935. * @returns min number array and max number array
  77936. */
  77937. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77938. min: number[];
  77939. max: number[];
  77940. };
  77941. /**
  77942. * Converts a new right-handed Vector3
  77943. * @param vector vector3 array
  77944. * @returns right-handed Vector3
  77945. */
  77946. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77947. /**
  77948. * Converts a Vector3 to right-handed
  77949. * @param vector Vector3 to convert to right-handed
  77950. */
  77951. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77952. /**
  77953. * Converts a three element number array to right-handed
  77954. * @param vector number array to convert to right-handed
  77955. */
  77956. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77957. /**
  77958. * Converts a new right-handed Vector3
  77959. * @param vector vector3 array
  77960. * @returns right-handed Vector3
  77961. */
  77962. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77963. /**
  77964. * Converts a Vector3 to right-handed
  77965. * @param vector Vector3 to convert to right-handed
  77966. */
  77967. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77968. /**
  77969. * Converts a three element number array to right-handed
  77970. * @param vector number array to convert to right-handed
  77971. */
  77972. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77973. /**
  77974. * Converts a Vector4 to right-handed
  77975. * @param vector Vector4 to convert to right-handed
  77976. */
  77977. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77978. /**
  77979. * Converts a Vector4 to right-handed
  77980. * @param vector Vector4 to convert to right-handed
  77981. */
  77982. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77983. /**
  77984. * Converts a Quaternion to right-handed
  77985. * @param quaternion Source quaternion to convert to right-handed
  77986. */
  77987. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77988. /**
  77989. * Converts a Quaternion to right-handed
  77990. * @param quaternion Source quaternion to convert to right-handed
  77991. */
  77992. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77993. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77994. }
  77995. }
  77996. declare module BABYLON.GLTF2.Exporter {
  77997. /**
  77998. * Converts Babylon Scene into glTF 2.0.
  77999. * @hidden
  78000. */
  78001. export class _Exporter {
  78002. /**
  78003. * Stores the glTF to export
  78004. */
  78005. _glTF: IGLTF;
  78006. /**
  78007. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78008. */
  78009. _bufferViews: IBufferView[];
  78010. /**
  78011. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78012. */
  78013. _accessors: IAccessor[];
  78014. /**
  78015. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78016. */
  78017. _nodes: INode[];
  78018. /**
  78019. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78020. */
  78021. private _scenes;
  78022. /**
  78023. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78024. */
  78025. private _meshes;
  78026. /**
  78027. * Stores all the generated material information, which represents the appearance of each primitive
  78028. */
  78029. _materials: IMaterial[];
  78030. _materialMap: {
  78031. [materialID: number]: number;
  78032. };
  78033. /**
  78034. * Stores all the generated texture information, which is referenced by glTF materials
  78035. */
  78036. _textures: ITexture[];
  78037. /**
  78038. * Stores all the generated image information, which is referenced by glTF textures
  78039. */
  78040. _images: IImage[];
  78041. /**
  78042. * Stores all the texture samplers
  78043. */
  78044. _samplers: ISampler[];
  78045. /**
  78046. * Stores all the generated animation samplers, which is referenced by glTF animations
  78047. */
  78048. /**
  78049. * Stores the animations for glTF models
  78050. */
  78051. private _animations;
  78052. /**
  78053. * Stores the total amount of bytes stored in the glTF buffer
  78054. */
  78055. private _totalByteLength;
  78056. /**
  78057. * Stores a reference to the Babylon scene containing the source geometry and material information
  78058. */
  78059. _babylonScene: Scene;
  78060. /**
  78061. * Stores a map of the image data, where the key is the file name and the value
  78062. * is the image data
  78063. */
  78064. _imageData: {
  78065. [fileName: string]: {
  78066. data: Uint8Array;
  78067. mimeType: ImageMimeType;
  78068. };
  78069. };
  78070. /**
  78071. * Stores a map of the unique id of a node to its index in the node array
  78072. */
  78073. _nodeMap: {
  78074. [key: number]: number;
  78075. };
  78076. /**
  78077. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78078. */
  78079. _convertToRightHandedSystem: boolean;
  78080. /**
  78081. * Specifies if a Babylon node should be converted to right-handed on export
  78082. */
  78083. _convertToRightHandedSystemMap: {
  78084. [nodeId: number]: boolean;
  78085. };
  78086. _includeCoordinateSystemConversionNodes: boolean;
  78087. /**
  78088. * Baked animation sample rate
  78089. */
  78090. private _animationSampleRate;
  78091. private _options;
  78092. private _localEngine;
  78093. _glTFMaterialExporter: _GLTFMaterialExporter;
  78094. private _extensions;
  78095. private static _ExtensionNames;
  78096. private static _ExtensionFactories;
  78097. private _applyExtension;
  78098. private _applyExtensions;
  78099. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78100. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78101. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78102. [key: number]: number;
  78103. }): Promise<Nullable<INode>>;
  78104. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78105. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78106. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78107. private _forEachExtensions;
  78108. private _extensionsOnExporting;
  78109. /**
  78110. * Load glTF serializer extensions
  78111. */
  78112. private _loadExtensions;
  78113. /**
  78114. * Creates a glTF Exporter instance, which can accept optional exporter options
  78115. * @param babylonScene Babylon scene object
  78116. * @param options Options to modify the behavior of the exporter
  78117. */
  78118. constructor(babylonScene: Scene, options?: IExportOptions);
  78119. dispose(): void;
  78120. /**
  78121. * Registers a glTF exporter extension
  78122. * @param name Name of the extension to export
  78123. * @param factory The factory function that creates the exporter extension
  78124. */
  78125. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78126. /**
  78127. * Un-registers an exporter extension
  78128. * @param name The name fo the exporter extension
  78129. * @returns A boolean indicating whether the extension has been un-registered
  78130. */
  78131. static UnregisterExtension(name: string): boolean;
  78132. /**
  78133. * Lazy load a local engine
  78134. */
  78135. _getLocalEngine(): Engine;
  78136. private reorderIndicesBasedOnPrimitiveMode;
  78137. /**
  78138. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78139. * clock-wise during export to glTF
  78140. * @param submesh BabylonJS submesh
  78141. * @param primitiveMode Primitive mode of the mesh
  78142. * @param sideOrientation the winding order of the submesh
  78143. * @param vertexBufferKind The type of vertex attribute
  78144. * @param meshAttributeArray The vertex attribute data
  78145. * @param byteOffset The offset to the binary data
  78146. * @param binaryWriter The binary data for the glTF file
  78147. * @param convertToRightHandedSystem Converts the values to right-handed
  78148. */
  78149. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78150. /**
  78151. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78152. * clock-wise during export to glTF
  78153. * @param submesh BabylonJS submesh
  78154. * @param primitiveMode Primitive mode of the mesh
  78155. * @param sideOrientation the winding order of the submesh
  78156. * @param vertexBufferKind The type of vertex attribute
  78157. * @param meshAttributeArray The vertex attribute data
  78158. * @param byteOffset The offset to the binary data
  78159. * @param binaryWriter The binary data for the glTF file
  78160. * @param convertToRightHandedSystem Converts the values to right-handed
  78161. */
  78162. private reorderTriangleFillMode;
  78163. /**
  78164. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78165. * clock-wise during export to glTF
  78166. * @param submesh BabylonJS submesh
  78167. * @param primitiveMode Primitive mode of the mesh
  78168. * @param sideOrientation the winding order of the submesh
  78169. * @param vertexBufferKind The type of vertex attribute
  78170. * @param meshAttributeArray The vertex attribute data
  78171. * @param byteOffset The offset to the binary data
  78172. * @param binaryWriter The binary data for the glTF file
  78173. * @param convertToRightHandedSystem Converts the values to right-handed
  78174. */
  78175. private reorderTriangleStripDrawMode;
  78176. /**
  78177. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78178. * clock-wise during export to glTF
  78179. * @param submesh BabylonJS submesh
  78180. * @param primitiveMode Primitive mode of the mesh
  78181. * @param sideOrientation the winding order of the submesh
  78182. * @param vertexBufferKind The type of vertex attribute
  78183. * @param meshAttributeArray The vertex attribute data
  78184. * @param byteOffset The offset to the binary data
  78185. * @param binaryWriter The binary data for the glTF file
  78186. * @param convertToRightHandedSystem Converts the values to right-handed
  78187. */
  78188. private reorderTriangleFanMode;
  78189. /**
  78190. * Writes the vertex attribute data to binary
  78191. * @param vertices The vertices to write to the binary writer
  78192. * @param byteOffset The offset into the binary writer to overwrite binary data
  78193. * @param vertexAttributeKind The vertex attribute type
  78194. * @param meshAttributeArray The vertex attribute data
  78195. * @param binaryWriter The writer containing the binary data
  78196. * @param convertToRightHandedSystem Converts the values to right-handed
  78197. */
  78198. private writeVertexAttributeData;
  78199. /**
  78200. * Writes mesh attribute data to a data buffer
  78201. * Returns the bytelength of the data
  78202. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78203. * @param meshAttributeArray Array containing the attribute data
  78204. * @param binaryWriter The buffer to write the binary data to
  78205. * @param indices Used to specify the order of the vertex data
  78206. * @param convertToRightHandedSystem Converts the values to right-handed
  78207. */
  78208. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78209. /**
  78210. * Generates glTF json data
  78211. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78212. * @param glTFPrefix Text to use when prefixing a glTF file
  78213. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78214. * @returns json data as string
  78215. */
  78216. private generateJSON;
  78217. /**
  78218. * Generates data for .gltf and .bin files based on the glTF prefix string
  78219. * @param glTFPrefix Text to use when prefixing a glTF file
  78220. * @param dispose Dispose the exporter
  78221. * @returns GLTFData with glTF file data
  78222. */
  78223. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78224. /**
  78225. * Creates a binary buffer for glTF
  78226. * @returns array buffer for binary data
  78227. */
  78228. private _generateBinaryAsync;
  78229. /**
  78230. * Pads the number to a multiple of 4
  78231. * @param num number to pad
  78232. * @returns padded number
  78233. */
  78234. private _getPadding;
  78235. /**
  78236. * @hidden
  78237. */
  78238. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78239. /**
  78240. * Sets the TRS for each node
  78241. * @param node glTF Node for storing the transformation data
  78242. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78243. * @param convertToRightHandedSystem Converts the values to right-handed
  78244. */
  78245. private setNodeTransformation;
  78246. private getVertexBufferFromMesh;
  78247. /**
  78248. * Creates a bufferview based on the vertices type for the Babylon mesh
  78249. * @param kind Indicates the type of vertices data
  78250. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78251. * @param binaryWriter The buffer to write the bufferview data to
  78252. * @param convertToRightHandedSystem Converts the values to right-handed
  78253. */
  78254. private createBufferViewKind;
  78255. /**
  78256. * The primitive mode of the Babylon mesh
  78257. * @param babylonMesh The BabylonJS mesh
  78258. */
  78259. private getMeshPrimitiveMode;
  78260. /**
  78261. * Sets the primitive mode of the glTF mesh primitive
  78262. * @param meshPrimitive glTF mesh primitive
  78263. * @param primitiveMode The primitive mode
  78264. */
  78265. private setPrimitiveMode;
  78266. /**
  78267. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78268. * @param meshPrimitive glTF mesh primitive
  78269. * @param attributeKind vertex attribute
  78270. * @returns boolean specifying if uv coordinates are present
  78271. */
  78272. private setAttributeKind;
  78273. /**
  78274. * Sets data for the primitive attributes of each submesh
  78275. * @param mesh glTF Mesh object to store the primitive attribute information
  78276. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78277. * @param binaryWriter Buffer to write the attribute data to
  78278. * @param convertToRightHandedSystem Converts the values to right-handed
  78279. */
  78280. private setPrimitiveAttributesAsync;
  78281. /**
  78282. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78283. * @param node The node to check
  78284. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78285. */
  78286. private isBabylonCoordinateSystemConvertingNode;
  78287. /**
  78288. * Creates a glTF scene based on the array of meshes
  78289. * Returns the the total byte offset
  78290. * @param babylonScene Babylon scene to get the mesh data from
  78291. * @param binaryWriter Buffer to write binary data to
  78292. */
  78293. private createSceneAsync;
  78294. /**
  78295. * Creates a mapping of Node unique id to node index and handles animations
  78296. * @param babylonScene Babylon Scene
  78297. * @param nodes Babylon transform nodes
  78298. * @param binaryWriter Buffer to write binary data to
  78299. * @returns Node mapping of unique id to index
  78300. */
  78301. private createNodeMapAndAnimationsAsync;
  78302. /**
  78303. * Creates a glTF node from a Babylon mesh
  78304. * @param babylonMesh Source Babylon mesh
  78305. * @param binaryWriter Buffer for storing geometry data
  78306. * @param convertToRightHandedSystem Converts the values to right-handed
  78307. * @param nodeMap Node mapping of unique id to glTF node index
  78308. * @returns glTF node
  78309. */
  78310. private createNodeAsync;
  78311. }
  78312. /**
  78313. * @hidden
  78314. *
  78315. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78316. */
  78317. export class _BinaryWriter {
  78318. /**
  78319. * Array buffer which stores all binary data
  78320. */
  78321. private _arrayBuffer;
  78322. /**
  78323. * View of the array buffer
  78324. */
  78325. private _dataView;
  78326. /**
  78327. * byte offset of data in array buffer
  78328. */
  78329. private _byteOffset;
  78330. /**
  78331. * Initialize binary writer with an initial byte length
  78332. * @param byteLength Initial byte length of the array buffer
  78333. */
  78334. constructor(byteLength: number);
  78335. /**
  78336. * Resize the array buffer to the specified byte length
  78337. * @param byteLength
  78338. */
  78339. private resizeBuffer;
  78340. /**
  78341. * Get an array buffer with the length of the byte offset
  78342. * @returns ArrayBuffer resized to the byte offset
  78343. */
  78344. getArrayBuffer(): ArrayBuffer;
  78345. /**
  78346. * Get the byte offset of the array buffer
  78347. * @returns byte offset
  78348. */
  78349. getByteOffset(): number;
  78350. /**
  78351. * Stores an UInt8 in the array buffer
  78352. * @param entry
  78353. * @param byteOffset If defined, specifies where to set the value as an offset.
  78354. */
  78355. setUInt8(entry: number, byteOffset?: number): void;
  78356. /**
  78357. * Gets an UInt32 in the array buffer
  78358. * @param entry
  78359. * @param byteOffset If defined, specifies where to set the value as an offset.
  78360. */
  78361. getUInt32(byteOffset: number): number;
  78362. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78363. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78364. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78365. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78366. /**
  78367. * Stores a Float32 in the array buffer
  78368. * @param entry
  78369. */
  78370. setFloat32(entry: number, byteOffset?: number): void;
  78371. /**
  78372. * Stores an UInt32 in the array buffer
  78373. * @param entry
  78374. * @param byteOffset If defined, specifies where to set the value as an offset.
  78375. */
  78376. setUInt32(entry: number, byteOffset?: number): void;
  78377. }
  78378. }
  78379. declare module BABYLON.GLTF2.Exporter {
  78380. /**
  78381. * @hidden
  78382. * Interface to store animation data.
  78383. */
  78384. export interface _IAnimationData {
  78385. /**
  78386. * Keyframe data.
  78387. */
  78388. inputs: number[];
  78389. /**
  78390. * Value data.
  78391. */
  78392. outputs: number[][];
  78393. /**
  78394. * Animation interpolation data.
  78395. */
  78396. samplerInterpolation: AnimationSamplerInterpolation;
  78397. /**
  78398. * Minimum keyframe value.
  78399. */
  78400. inputsMin: number;
  78401. /**
  78402. * Maximum keyframe value.
  78403. */
  78404. inputsMax: number;
  78405. }
  78406. /**
  78407. * @hidden
  78408. */
  78409. export interface _IAnimationInfo {
  78410. /**
  78411. * The target channel for the animation
  78412. */
  78413. animationChannelTargetPath: AnimationChannelTargetPath;
  78414. /**
  78415. * The glTF accessor type for the data.
  78416. */
  78417. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78418. /**
  78419. * Specifies if quaternions should be used.
  78420. */
  78421. useQuaternion: boolean;
  78422. }
  78423. /**
  78424. * @hidden
  78425. * Utility class for generating glTF animation data from BabylonJS.
  78426. */
  78427. export class _GLTFAnimation {
  78428. /**
  78429. * @ignore
  78430. *
  78431. * Creates glTF channel animation from BabylonJS animation.
  78432. * @param babylonTransformNode - BabylonJS mesh.
  78433. * @param animation - animation.
  78434. * @param animationChannelTargetPath - The target animation channel.
  78435. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78436. * @param useQuaternion - Specifies if quaternions are used.
  78437. * @returns nullable IAnimationData
  78438. */
  78439. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78440. private static _DeduceAnimationInfo;
  78441. /**
  78442. * @ignore
  78443. * Create node animations from the transform node animations
  78444. * @param babylonNode
  78445. * @param runtimeGLTFAnimation
  78446. * @param idleGLTFAnimations
  78447. * @param nodeMap
  78448. * @param nodes
  78449. * @param binaryWriter
  78450. * @param bufferViews
  78451. * @param accessors
  78452. * @param convertToRightHandedSystem
  78453. * @param animationSampleRate
  78454. */
  78455. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78456. [key: number]: number;
  78457. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78458. /**
  78459. * @ignore
  78460. * Create node animations from the animation groups
  78461. * @param babylonScene
  78462. * @param glTFAnimations
  78463. * @param nodeMap
  78464. * @param nodes
  78465. * @param binaryWriter
  78466. * @param bufferViews
  78467. * @param accessors
  78468. * @param convertToRightHandedSystemMap
  78469. * @param animationSampleRate
  78470. */
  78471. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78472. [key: number]: number;
  78473. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78474. [nodeId: number]: boolean;
  78475. }, animationSampleRate: number): void;
  78476. private static AddAnimation;
  78477. /**
  78478. * Create a baked animation
  78479. * @param babylonTransformNode BabylonJS mesh
  78480. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78481. * @param animationChannelTargetPath animation target channel
  78482. * @param minFrame minimum animation frame
  78483. * @param maxFrame maximum animation frame
  78484. * @param fps frames per second of the animation
  78485. * @param inputs input key frames of the animation
  78486. * @param outputs output key frame data of the animation
  78487. * @param convertToRightHandedSystem converts the values to right-handed
  78488. * @param useQuaternion specifies if quaternions should be used
  78489. */
  78490. private static _CreateBakedAnimation;
  78491. private static _ConvertFactorToVector3OrQuaternion;
  78492. private static _SetInterpolatedValue;
  78493. /**
  78494. * Creates linear animation from the animation key frames
  78495. * @param babylonTransformNode BabylonJS mesh
  78496. * @param animation BabylonJS animation
  78497. * @param animationChannelTargetPath The target animation channel
  78498. * @param frameDelta The difference between the last and first frame of the animation
  78499. * @param inputs Array to store the key frame times
  78500. * @param outputs Array to store the key frame data
  78501. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78502. * @param useQuaternion Specifies if quaternions are used in the animation
  78503. */
  78504. private static _CreateLinearOrStepAnimation;
  78505. /**
  78506. * Creates cubic spline animation from the animation key frames
  78507. * @param babylonTransformNode BabylonJS mesh
  78508. * @param animation BabylonJS animation
  78509. * @param animationChannelTargetPath The target animation channel
  78510. * @param frameDelta The difference between the last and first frame of the animation
  78511. * @param inputs Array to store the key frame times
  78512. * @param outputs Array to store the key frame data
  78513. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78514. * @param useQuaternion Specifies if quaternions are used in the animation
  78515. */
  78516. private static _CreateCubicSplineAnimation;
  78517. private static _GetBasePositionRotationOrScale;
  78518. /**
  78519. * Adds a key frame value
  78520. * @param keyFrame
  78521. * @param animation
  78522. * @param outputs
  78523. * @param animationChannelTargetPath
  78524. * @param basePositionRotationOrScale
  78525. * @param convertToRightHandedSystem
  78526. * @param useQuaternion
  78527. */
  78528. private static _AddKeyframeValue;
  78529. /**
  78530. * Determine the interpolation based on the key frames
  78531. * @param keyFrames
  78532. * @param animationChannelTargetPath
  78533. * @param useQuaternion
  78534. */
  78535. private static _DeduceInterpolation;
  78536. /**
  78537. * Adds an input tangent or output tangent to the output data
  78538. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78539. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78540. * @param outputs The animation data by keyframe
  78541. * @param animationChannelTargetPath The target animation channel
  78542. * @param interpolation The interpolation type
  78543. * @param keyFrame The key frame with the animation data
  78544. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78545. * @param useQuaternion Specifies if quaternions are used
  78546. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78547. */
  78548. private static AddSplineTangent;
  78549. /**
  78550. * Get the minimum and maximum key frames' frame values
  78551. * @param keyFrames animation key frames
  78552. * @returns the minimum and maximum key frame value
  78553. */
  78554. private static calculateMinMaxKeyFrames;
  78555. }
  78556. }
  78557. declare module BABYLON.GLTF2.Exporter {
  78558. /** @hidden */
  78559. export var textureTransformPixelShader: {
  78560. name: string;
  78561. shader: string;
  78562. };
  78563. }
  78564. declare module BABYLON.GLTF2.Exporter.Extensions {
  78565. /**
  78566. * @hidden
  78567. */
  78568. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78569. private _recordedTextures;
  78570. /** Name of this extension */
  78571. readonly name: string;
  78572. /** Defines whether this extension is enabled */
  78573. enabled: boolean;
  78574. /** Defines whether this extension is required */
  78575. required: boolean;
  78576. /** Reference to the glTF exporter */
  78577. private _wasUsed;
  78578. constructor(exporter: _Exporter);
  78579. dispose(): void;
  78580. /** @hidden */
  78581. get wasUsed(): boolean;
  78582. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78583. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78584. /**
  78585. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78586. * @param babylonTexture
  78587. * @param offset
  78588. * @param rotation
  78589. * @param scale
  78590. * @param scene
  78591. */
  78592. private _textureTransformTextureAsync;
  78593. }
  78594. }
  78595. declare module BABYLON.GLTF2.Exporter.Extensions {
  78596. /**
  78597. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78598. */
  78599. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78600. /** The name of this extension. */
  78601. readonly name: string;
  78602. /** Defines whether this extension is enabled. */
  78603. enabled: boolean;
  78604. /** Defines whether this extension is required */
  78605. required: boolean;
  78606. /** Reference to the glTF exporter */
  78607. private _exporter;
  78608. private _lights;
  78609. /** @hidden */
  78610. constructor(exporter: _Exporter);
  78611. /** @hidden */
  78612. dispose(): void;
  78613. /** @hidden */
  78614. get wasUsed(): boolean;
  78615. /** @hidden */
  78616. onExporting(): void;
  78617. /**
  78618. * Define this method to modify the default behavior when exporting a node
  78619. * @param context The context when exporting the node
  78620. * @param node glTF node
  78621. * @param babylonNode BabylonJS node
  78622. * @param nodeMap Node mapping of unique id to glTF node index
  78623. * @returns nullable INode promise
  78624. */
  78625. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78626. [key: number]: number;
  78627. }): Promise<Nullable<INode>>;
  78628. }
  78629. }
  78630. declare module BABYLON.GLTF2.Exporter.Extensions {
  78631. /**
  78632. * @hidden
  78633. */
  78634. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78635. /** Name of this extension */
  78636. readonly name: string;
  78637. /** Defines whether this extension is enabled */
  78638. enabled: boolean;
  78639. /** Defines whether this extension is required */
  78640. required: boolean;
  78641. /** Reference to the glTF exporter */
  78642. private _textureInfos;
  78643. private _exportedTextures;
  78644. private _wasUsed;
  78645. constructor(exporter: _Exporter);
  78646. dispose(): void;
  78647. /** @hidden */
  78648. get wasUsed(): boolean;
  78649. private _getTextureIndex;
  78650. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78651. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78652. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78653. }
  78654. }
  78655. declare module BABYLON {
  78656. /**
  78657. * Class for generating STL data from a Babylon scene.
  78658. */
  78659. export class STLExport {
  78660. /**
  78661. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78662. * @param meshes list defines the mesh to serialize
  78663. * @param download triggers the automatic download of the file.
  78664. * @param fileName changes the downloads fileName.
  78665. * @param binary changes the STL to a binary type.
  78666. * @param isLittleEndian toggle for binary type exporter.
  78667. * @returns the STL as UTF8 string
  78668. */
  78669. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78670. }
  78671. }
  78672. declare module "babylonjs-gltf2interface" {
  78673. export = BABYLON.GLTF2;
  78674. }
  78675. /**
  78676. * Module for glTF 2.0 Interface
  78677. */
  78678. declare module BABYLON.GLTF2 {
  78679. /**
  78680. * The datatype of the components in the attribute
  78681. */
  78682. const enum AccessorComponentType {
  78683. /**
  78684. * Byte
  78685. */
  78686. BYTE = 5120,
  78687. /**
  78688. * Unsigned Byte
  78689. */
  78690. UNSIGNED_BYTE = 5121,
  78691. /**
  78692. * Short
  78693. */
  78694. SHORT = 5122,
  78695. /**
  78696. * Unsigned Short
  78697. */
  78698. UNSIGNED_SHORT = 5123,
  78699. /**
  78700. * Unsigned Int
  78701. */
  78702. UNSIGNED_INT = 5125,
  78703. /**
  78704. * Float
  78705. */
  78706. FLOAT = 5126,
  78707. }
  78708. /**
  78709. * Specifies if the attirbute is a scalar, vector, or matrix
  78710. */
  78711. const enum AccessorType {
  78712. /**
  78713. * Scalar
  78714. */
  78715. SCALAR = "SCALAR",
  78716. /**
  78717. * Vector2
  78718. */
  78719. VEC2 = "VEC2",
  78720. /**
  78721. * Vector3
  78722. */
  78723. VEC3 = "VEC3",
  78724. /**
  78725. * Vector4
  78726. */
  78727. VEC4 = "VEC4",
  78728. /**
  78729. * Matrix2x2
  78730. */
  78731. MAT2 = "MAT2",
  78732. /**
  78733. * Matrix3x3
  78734. */
  78735. MAT3 = "MAT3",
  78736. /**
  78737. * Matrix4x4
  78738. */
  78739. MAT4 = "MAT4",
  78740. }
  78741. /**
  78742. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78743. */
  78744. const enum AnimationChannelTargetPath {
  78745. /**
  78746. * Translation
  78747. */
  78748. TRANSLATION = "translation",
  78749. /**
  78750. * Rotation
  78751. */
  78752. ROTATION = "rotation",
  78753. /**
  78754. * Scale
  78755. */
  78756. SCALE = "scale",
  78757. /**
  78758. * Weights
  78759. */
  78760. WEIGHTS = "weights",
  78761. }
  78762. /**
  78763. * Interpolation algorithm
  78764. */
  78765. const enum AnimationSamplerInterpolation {
  78766. /**
  78767. * The animated values are linearly interpolated between keyframes
  78768. */
  78769. LINEAR = "LINEAR",
  78770. /**
  78771. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78772. */
  78773. STEP = "STEP",
  78774. /**
  78775. * The animation's interpolation is computed using a cubic spline with specified tangents
  78776. */
  78777. CUBICSPLINE = "CUBICSPLINE",
  78778. }
  78779. /**
  78780. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78781. */
  78782. const enum CameraType {
  78783. /**
  78784. * A perspective camera containing properties to create a perspective projection matrix
  78785. */
  78786. PERSPECTIVE = "perspective",
  78787. /**
  78788. * An orthographic camera containing properties to create an orthographic projection matrix
  78789. */
  78790. ORTHOGRAPHIC = "orthographic",
  78791. }
  78792. /**
  78793. * The mime-type of the image
  78794. */
  78795. const enum ImageMimeType {
  78796. /**
  78797. * JPEG Mime-type
  78798. */
  78799. JPEG = "image/jpeg",
  78800. /**
  78801. * PNG Mime-type
  78802. */
  78803. PNG = "image/png",
  78804. }
  78805. /**
  78806. * The alpha rendering mode of the material
  78807. */
  78808. const enum MaterialAlphaMode {
  78809. /**
  78810. * The alpha value is ignored and the rendered output is fully opaque
  78811. */
  78812. OPAQUE = "OPAQUE",
  78813. /**
  78814. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78815. */
  78816. MASK = "MASK",
  78817. /**
  78818. * 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)
  78819. */
  78820. BLEND = "BLEND",
  78821. }
  78822. /**
  78823. * The type of the primitives to render
  78824. */
  78825. const enum MeshPrimitiveMode {
  78826. /**
  78827. * Points
  78828. */
  78829. POINTS = 0,
  78830. /**
  78831. * Lines
  78832. */
  78833. LINES = 1,
  78834. /**
  78835. * Line Loop
  78836. */
  78837. LINE_LOOP = 2,
  78838. /**
  78839. * Line Strip
  78840. */
  78841. LINE_STRIP = 3,
  78842. /**
  78843. * Triangles
  78844. */
  78845. TRIANGLES = 4,
  78846. /**
  78847. * Triangle Strip
  78848. */
  78849. TRIANGLE_STRIP = 5,
  78850. /**
  78851. * Triangle Fan
  78852. */
  78853. TRIANGLE_FAN = 6,
  78854. }
  78855. /**
  78856. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78857. */
  78858. const enum TextureMagFilter {
  78859. /**
  78860. * Nearest
  78861. */
  78862. NEAREST = 9728,
  78863. /**
  78864. * Linear
  78865. */
  78866. LINEAR = 9729,
  78867. }
  78868. /**
  78869. * Minification filter. All valid values correspond to WebGL enums
  78870. */
  78871. const enum TextureMinFilter {
  78872. /**
  78873. * Nearest
  78874. */
  78875. NEAREST = 9728,
  78876. /**
  78877. * Linear
  78878. */
  78879. LINEAR = 9729,
  78880. /**
  78881. * Nearest Mip-Map Nearest
  78882. */
  78883. NEAREST_MIPMAP_NEAREST = 9984,
  78884. /**
  78885. * Linear Mipmap Nearest
  78886. */
  78887. LINEAR_MIPMAP_NEAREST = 9985,
  78888. /**
  78889. * Nearest Mipmap Linear
  78890. */
  78891. NEAREST_MIPMAP_LINEAR = 9986,
  78892. /**
  78893. * Linear Mipmap Linear
  78894. */
  78895. LINEAR_MIPMAP_LINEAR = 9987,
  78896. }
  78897. /**
  78898. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78899. */
  78900. const enum TextureWrapMode {
  78901. /**
  78902. * Clamp to Edge
  78903. */
  78904. CLAMP_TO_EDGE = 33071,
  78905. /**
  78906. * Mirrored Repeat
  78907. */
  78908. MIRRORED_REPEAT = 33648,
  78909. /**
  78910. * Repeat
  78911. */
  78912. REPEAT = 10497,
  78913. }
  78914. /**
  78915. * glTF Property
  78916. */
  78917. interface IProperty {
  78918. /**
  78919. * Dictionary object with extension-specific objects
  78920. */
  78921. extensions?: {
  78922. [key: string]: any;
  78923. };
  78924. /**
  78925. * Application-Specific data
  78926. */
  78927. extras?: any;
  78928. }
  78929. /**
  78930. * glTF Child of Root Property
  78931. */
  78932. interface IChildRootProperty extends IProperty {
  78933. /**
  78934. * The user-defined name of this object
  78935. */
  78936. name?: string;
  78937. }
  78938. /**
  78939. * Indices of those attributes that deviate from their initialization value
  78940. */
  78941. interface IAccessorSparseIndices extends IProperty {
  78942. /**
  78943. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78944. */
  78945. bufferView: number;
  78946. /**
  78947. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78948. */
  78949. byteOffset?: number;
  78950. /**
  78951. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78952. */
  78953. componentType: AccessorComponentType;
  78954. }
  78955. /**
  78956. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78957. */
  78958. interface IAccessorSparseValues extends IProperty {
  78959. /**
  78960. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78961. */
  78962. bufferView: number;
  78963. /**
  78964. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78965. */
  78966. byteOffset?: number;
  78967. }
  78968. /**
  78969. * Sparse storage of attributes that deviate from their initialization value
  78970. */
  78971. interface IAccessorSparse extends IProperty {
  78972. /**
  78973. * The number of attributes encoded in this sparse accessor
  78974. */
  78975. count: number;
  78976. /**
  78977. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78978. */
  78979. indices: IAccessorSparseIndices;
  78980. /**
  78981. * 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
  78982. */
  78983. values: IAccessorSparseValues;
  78984. }
  78985. /**
  78986. * 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
  78987. */
  78988. interface IAccessor extends IChildRootProperty {
  78989. /**
  78990. * The index of the bufferview
  78991. */
  78992. bufferView?: number;
  78993. /**
  78994. * The offset relative to the start of the bufferView in bytes
  78995. */
  78996. byteOffset?: number;
  78997. /**
  78998. * The datatype of components in the attribute
  78999. */
  79000. componentType: AccessorComponentType;
  79001. /**
  79002. * Specifies whether integer data values should be normalized
  79003. */
  79004. normalized?: boolean;
  79005. /**
  79006. * The number of attributes referenced by this accessor
  79007. */
  79008. count: number;
  79009. /**
  79010. * Specifies if the attribute is a scalar, vector, or matrix
  79011. */
  79012. type: AccessorType;
  79013. /**
  79014. * Maximum value of each component in this attribute
  79015. */
  79016. max?: number[];
  79017. /**
  79018. * Minimum value of each component in this attribute
  79019. */
  79020. min?: number[];
  79021. /**
  79022. * Sparse storage of attributes that deviate from their initialization value
  79023. */
  79024. sparse?: IAccessorSparse;
  79025. }
  79026. /**
  79027. * Targets an animation's sampler at a node's property
  79028. */
  79029. interface IAnimationChannel extends IProperty {
  79030. /**
  79031. * The index of a sampler in this animation used to compute the value for the target
  79032. */
  79033. sampler: number;
  79034. /**
  79035. * The index of the node and TRS property to target
  79036. */
  79037. target: IAnimationChannelTarget;
  79038. }
  79039. /**
  79040. * The index of the node and TRS property that an animation channel targets
  79041. */
  79042. interface IAnimationChannelTarget extends IProperty {
  79043. /**
  79044. * The index of the node to target
  79045. */
  79046. node: number;
  79047. /**
  79048. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79049. */
  79050. path: AnimationChannelTargetPath;
  79051. }
  79052. /**
  79053. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79054. */
  79055. interface IAnimationSampler extends IProperty {
  79056. /**
  79057. * The index of an accessor containing keyframe input values, e.g., time
  79058. */
  79059. input: number;
  79060. /**
  79061. * Interpolation algorithm
  79062. */
  79063. interpolation?: AnimationSamplerInterpolation;
  79064. /**
  79065. * The index of an accessor, containing keyframe output values
  79066. */
  79067. output: number;
  79068. }
  79069. /**
  79070. * A keyframe animation
  79071. */
  79072. interface IAnimation extends IChildRootProperty {
  79073. /**
  79074. * An array of channels, each of which targets an animation's sampler at a node's property
  79075. */
  79076. channels: IAnimationChannel[];
  79077. /**
  79078. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79079. */
  79080. samplers: IAnimationSampler[];
  79081. }
  79082. /**
  79083. * Metadata about the glTF asset
  79084. */
  79085. interface IAsset extends IChildRootProperty {
  79086. /**
  79087. * A copyright message suitable for display to credit the content creator
  79088. */
  79089. copyright?: string;
  79090. /**
  79091. * Tool that generated this glTF model. Useful for debugging
  79092. */
  79093. generator?: string;
  79094. /**
  79095. * The glTF version that this asset targets
  79096. */
  79097. version: string;
  79098. /**
  79099. * The minimum glTF version that this asset targets
  79100. */
  79101. minVersion?: string;
  79102. }
  79103. /**
  79104. * A buffer points to binary geometry, animation, or skins
  79105. */
  79106. interface IBuffer extends IChildRootProperty {
  79107. /**
  79108. * 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
  79109. */
  79110. uri?: string;
  79111. /**
  79112. * The length of the buffer in bytes
  79113. */
  79114. byteLength: number;
  79115. }
  79116. /**
  79117. * A view into a buffer generally representing a subset of the buffer
  79118. */
  79119. interface IBufferView extends IChildRootProperty {
  79120. /**
  79121. * The index of the buffer
  79122. */
  79123. buffer: number;
  79124. /**
  79125. * The offset into the buffer in bytes
  79126. */
  79127. byteOffset?: number;
  79128. /**
  79129. * The lenth of the bufferView in bytes
  79130. */
  79131. byteLength: number;
  79132. /**
  79133. * The stride, in bytes
  79134. */
  79135. byteStride?: number;
  79136. }
  79137. /**
  79138. * An orthographic camera containing properties to create an orthographic projection matrix
  79139. */
  79140. interface ICameraOrthographic extends IProperty {
  79141. /**
  79142. * The floating-point horizontal magnification of the view. Must not be zero
  79143. */
  79144. xmag: number;
  79145. /**
  79146. * The floating-point vertical magnification of the view. Must not be zero
  79147. */
  79148. ymag: number;
  79149. /**
  79150. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79151. */
  79152. zfar: number;
  79153. /**
  79154. * The floating-point distance to the near clipping plane
  79155. */
  79156. znear: number;
  79157. }
  79158. /**
  79159. * A perspective camera containing properties to create a perspective projection matrix
  79160. */
  79161. interface ICameraPerspective extends IProperty {
  79162. /**
  79163. * The floating-point aspect ratio of the field of view
  79164. */
  79165. aspectRatio?: number;
  79166. /**
  79167. * The floating-point vertical field of view in radians
  79168. */
  79169. yfov: number;
  79170. /**
  79171. * The floating-point distance to the far clipping plane
  79172. */
  79173. zfar?: number;
  79174. /**
  79175. * The floating-point distance to the near clipping plane
  79176. */
  79177. znear: number;
  79178. }
  79179. /**
  79180. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79181. */
  79182. interface ICamera extends IChildRootProperty {
  79183. /**
  79184. * An orthographic camera containing properties to create an orthographic projection matrix
  79185. */
  79186. orthographic?: ICameraOrthographic;
  79187. /**
  79188. * A perspective camera containing properties to create a perspective projection matrix
  79189. */
  79190. perspective?: ICameraPerspective;
  79191. /**
  79192. * Specifies if the camera uses a perspective or orthographic projection
  79193. */
  79194. type: CameraType;
  79195. }
  79196. /**
  79197. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79198. */
  79199. interface IImage extends IChildRootProperty {
  79200. /**
  79201. * 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
  79202. */
  79203. uri?: string;
  79204. /**
  79205. * The image's MIME type
  79206. */
  79207. mimeType?: ImageMimeType;
  79208. /**
  79209. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79210. */
  79211. bufferView?: number;
  79212. }
  79213. /**
  79214. * Material Normal Texture Info
  79215. */
  79216. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79217. /**
  79218. * The scalar multiplier applied to each normal vector of the normal texture
  79219. */
  79220. scale?: number;
  79221. }
  79222. /**
  79223. * Material Occlusion Texture Info
  79224. */
  79225. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79226. /**
  79227. * A scalar multiplier controlling the amount of occlusion applied
  79228. */
  79229. strength?: number;
  79230. }
  79231. /**
  79232. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79233. */
  79234. interface IMaterialPbrMetallicRoughness {
  79235. /**
  79236. * The material's base color factor
  79237. */
  79238. baseColorFactor?: number[];
  79239. /**
  79240. * The base color texture
  79241. */
  79242. baseColorTexture?: ITextureInfo;
  79243. /**
  79244. * The metalness of the material
  79245. */
  79246. metallicFactor?: number;
  79247. /**
  79248. * The roughness of the material
  79249. */
  79250. roughnessFactor?: number;
  79251. /**
  79252. * The metallic-roughness texture
  79253. */
  79254. metallicRoughnessTexture?: ITextureInfo;
  79255. }
  79256. /**
  79257. * The material appearance of a primitive
  79258. */
  79259. interface IMaterial extends IChildRootProperty {
  79260. /**
  79261. * 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
  79262. */
  79263. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79264. /**
  79265. * The normal map texture
  79266. */
  79267. normalTexture?: IMaterialNormalTextureInfo;
  79268. /**
  79269. * The occlusion map texture
  79270. */
  79271. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79272. /**
  79273. * The emissive map texture
  79274. */
  79275. emissiveTexture?: ITextureInfo;
  79276. /**
  79277. * 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
  79278. */
  79279. emissiveFactor?: number[];
  79280. /**
  79281. * The alpha rendering mode of the material
  79282. */
  79283. alphaMode?: MaterialAlphaMode;
  79284. /**
  79285. * The alpha cutoff value of the material
  79286. */
  79287. alphaCutoff?: number;
  79288. /**
  79289. * Specifies whether the material is double sided
  79290. */
  79291. doubleSided?: boolean;
  79292. }
  79293. /**
  79294. * Geometry to be rendered with the given material
  79295. */
  79296. interface IMeshPrimitive extends IProperty {
  79297. /**
  79298. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79299. */
  79300. attributes: {
  79301. [name: string]: number;
  79302. };
  79303. /**
  79304. * The index of the accessor that contains the indices
  79305. */
  79306. indices?: number;
  79307. /**
  79308. * The index of the material to apply to this primitive when rendering
  79309. */
  79310. material?: number;
  79311. /**
  79312. * The type of primitives to render. All valid values correspond to WebGL enums
  79313. */
  79314. mode?: MeshPrimitiveMode;
  79315. /**
  79316. * 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
  79317. */
  79318. targets?: {
  79319. [name: string]: number;
  79320. }[];
  79321. }
  79322. /**
  79323. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79324. */
  79325. interface IMesh extends IChildRootProperty {
  79326. /**
  79327. * An array of primitives, each defining geometry to be rendered with a material
  79328. */
  79329. primitives: IMeshPrimitive[];
  79330. /**
  79331. * Array of weights to be applied to the Morph Targets
  79332. */
  79333. weights?: number[];
  79334. }
  79335. /**
  79336. * A node in the node hierarchy
  79337. */
  79338. interface INode extends IChildRootProperty {
  79339. /**
  79340. * The index of the camera referenced by this node
  79341. */
  79342. camera?: number;
  79343. /**
  79344. * The indices of this node's children
  79345. */
  79346. children?: number[];
  79347. /**
  79348. * The index of the skin referenced by this node
  79349. */
  79350. skin?: number;
  79351. /**
  79352. * A floating-point 4x4 transformation matrix stored in column-major order
  79353. */
  79354. matrix?: number[];
  79355. /**
  79356. * The index of the mesh in this node
  79357. */
  79358. mesh?: number;
  79359. /**
  79360. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79361. */
  79362. rotation?: number[];
  79363. /**
  79364. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79365. */
  79366. scale?: number[];
  79367. /**
  79368. * The node's translation along the x, y, and z axes
  79369. */
  79370. translation?: number[];
  79371. /**
  79372. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79373. */
  79374. weights?: number[];
  79375. }
  79376. /**
  79377. * Texture sampler properties for filtering and wrapping modes
  79378. */
  79379. interface ISampler extends IChildRootProperty {
  79380. /**
  79381. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79382. */
  79383. magFilter?: TextureMagFilter;
  79384. /**
  79385. * Minification filter. All valid values correspond to WebGL enums
  79386. */
  79387. minFilter?: TextureMinFilter;
  79388. /**
  79389. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79390. */
  79391. wrapS?: TextureWrapMode;
  79392. /**
  79393. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79394. */
  79395. wrapT?: TextureWrapMode;
  79396. }
  79397. /**
  79398. * The root nodes of a scene
  79399. */
  79400. interface IScene extends IChildRootProperty {
  79401. /**
  79402. * The indices of each root node
  79403. */
  79404. nodes: number[];
  79405. }
  79406. /**
  79407. * Joints and matrices defining a skin
  79408. */
  79409. interface ISkin extends IChildRootProperty {
  79410. /**
  79411. * 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
  79412. */
  79413. inverseBindMatrices?: number;
  79414. /**
  79415. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79416. */
  79417. skeleton?: number;
  79418. /**
  79419. * 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)
  79420. */
  79421. joints: number[];
  79422. }
  79423. /**
  79424. * A texture and its sampler
  79425. */
  79426. interface ITexture extends IChildRootProperty {
  79427. /**
  79428. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79429. */
  79430. sampler?: number;
  79431. /**
  79432. * The index of the image used by this texture
  79433. */
  79434. source: number;
  79435. }
  79436. /**
  79437. * Reference to a texture
  79438. */
  79439. interface ITextureInfo extends IProperty {
  79440. /**
  79441. * The index of the texture
  79442. */
  79443. index: number;
  79444. /**
  79445. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79446. */
  79447. texCoord?: number;
  79448. }
  79449. /**
  79450. * The root object for a glTF asset
  79451. */
  79452. interface IGLTF extends IProperty {
  79453. /**
  79454. * An array of accessors. An accessor is a typed view into a bufferView
  79455. */
  79456. accessors?: IAccessor[];
  79457. /**
  79458. * An array of keyframe animations
  79459. */
  79460. animations?: IAnimation[];
  79461. /**
  79462. * Metadata about the glTF asset
  79463. */
  79464. asset: IAsset;
  79465. /**
  79466. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79467. */
  79468. buffers?: IBuffer[];
  79469. /**
  79470. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79471. */
  79472. bufferViews?: IBufferView[];
  79473. /**
  79474. * An array of cameras
  79475. */
  79476. cameras?: ICamera[];
  79477. /**
  79478. * Names of glTF extensions used somewhere in this asset
  79479. */
  79480. extensionsUsed?: string[];
  79481. /**
  79482. * Names of glTF extensions required to properly load this asset
  79483. */
  79484. extensionsRequired?: string[];
  79485. /**
  79486. * An array of images. An image defines data used to create a texture
  79487. */
  79488. images?: IImage[];
  79489. /**
  79490. * An array of materials. A material defines the appearance of a primitive
  79491. */
  79492. materials?: IMaterial[];
  79493. /**
  79494. * An array of meshes. A mesh is a set of primitives to be rendered
  79495. */
  79496. meshes?: IMesh[];
  79497. /**
  79498. * An array of nodes
  79499. */
  79500. nodes?: INode[];
  79501. /**
  79502. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79503. */
  79504. samplers?: ISampler[];
  79505. /**
  79506. * The index of the default scene
  79507. */
  79508. scene?: number;
  79509. /**
  79510. * An array of scenes
  79511. */
  79512. scenes?: IScene[];
  79513. /**
  79514. * An array of skins. A skin is defined by joints and matrices
  79515. */
  79516. skins?: ISkin[];
  79517. /**
  79518. * An array of textures
  79519. */
  79520. textures?: ITexture[];
  79521. }
  79522. /**
  79523. * The glTF validation results
  79524. * @ignore
  79525. */
  79526. interface IGLTFValidationResults {
  79527. info: {
  79528. generator: string;
  79529. hasAnimations: boolean;
  79530. hasDefaultScene: boolean;
  79531. hasMaterials: boolean;
  79532. hasMorphTargets: boolean;
  79533. hasSkins: boolean;
  79534. hasTextures: boolean;
  79535. maxAttributesUsed: number;
  79536. primitivesCount: number
  79537. };
  79538. issues: {
  79539. messages: Array<string>;
  79540. numErrors: number;
  79541. numHints: number;
  79542. numInfos: number;
  79543. numWarnings: number;
  79544. truncated: boolean
  79545. };
  79546. mimeType: string;
  79547. uri: string;
  79548. validatedAt: string;
  79549. validatorVersion: string;
  79550. }
  79551. /**
  79552. * The glTF validation options
  79553. */
  79554. interface IGLTFValidationOptions {
  79555. /** Uri to use */
  79556. uri?: string;
  79557. /** Function used to load external resources */
  79558. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79559. /** Boolean indicating that we need to validate accessor data */
  79560. validateAccessorData?: boolean;
  79561. /** max number of issues allowed */
  79562. maxIssues?: number;
  79563. /** Ignored issues */
  79564. ignoredIssues?: Array<string>;
  79565. /** Value to override severy settings */
  79566. severityOverrides?: Object;
  79567. }
  79568. /**
  79569. * The glTF validator object
  79570. * @ignore
  79571. */
  79572. interface IGLTFValidator {
  79573. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79574. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79575. }
  79576. }
  79577. declare module BABYLON {
  79578. /** @hidden */
  79579. export var cellPixelShader: {
  79580. name: string;
  79581. shader: string;
  79582. };
  79583. }
  79584. declare module BABYLON {
  79585. /** @hidden */
  79586. export var cellVertexShader: {
  79587. name: string;
  79588. shader: string;
  79589. };
  79590. }
  79591. declare module BABYLON {
  79592. export class CellMaterial extends BABYLON.PushMaterial {
  79593. private _diffuseTexture;
  79594. diffuseTexture: BABYLON.BaseTexture;
  79595. diffuseColor: BABYLON.Color3;
  79596. _computeHighLevel: boolean;
  79597. computeHighLevel: boolean;
  79598. private _disableLighting;
  79599. disableLighting: boolean;
  79600. private _maxSimultaneousLights;
  79601. maxSimultaneousLights: number;
  79602. constructor(name: string, scene: BABYLON.Scene);
  79603. needAlphaBlending(): boolean;
  79604. needAlphaTesting(): boolean;
  79605. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79606. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79607. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79608. getAnimatables(): BABYLON.IAnimatable[];
  79609. getActiveTextures(): BABYLON.BaseTexture[];
  79610. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79611. dispose(forceDisposeEffect?: boolean): void;
  79612. getClassName(): string;
  79613. clone(name: string): CellMaterial;
  79614. serialize(): any;
  79615. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79616. }
  79617. }
  79618. declare module BABYLON {
  79619. export class CustomShaderStructure {
  79620. FragmentStore: string;
  79621. VertexStore: string;
  79622. constructor();
  79623. }
  79624. export class ShaderSpecialParts {
  79625. constructor();
  79626. Fragment_Begin: string;
  79627. Fragment_Definitions: string;
  79628. Fragment_MainBegin: string;
  79629. Fragment_Custom_Diffuse: string;
  79630. Fragment_Before_Lights: string;
  79631. Fragment_Before_Fog: string;
  79632. Fragment_Custom_Alpha: string;
  79633. Fragment_Before_FragColor: string;
  79634. Vertex_Begin: string;
  79635. Vertex_Definitions: string;
  79636. Vertex_MainBegin: string;
  79637. Vertex_Before_PositionUpdated: string;
  79638. Vertex_Before_NormalUpdated: string;
  79639. Vertex_MainEnd: string;
  79640. }
  79641. export class CustomMaterial extends BABYLON.StandardMaterial {
  79642. static ShaderIndexer: number;
  79643. CustomParts: ShaderSpecialParts;
  79644. _isCreatedShader: boolean;
  79645. _createdShaderName: string;
  79646. _customUniform: string[];
  79647. _newUniforms: string[];
  79648. _newUniformInstances: any[];
  79649. _newSamplerInstances: BABYLON.Texture[];
  79650. _customAttributes: string[];
  79651. FragmentShader: string;
  79652. VertexShader: string;
  79653. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79654. ReviewUniform(name: string, arr: string[]): string[];
  79655. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79656. constructor(name: string, scene: BABYLON.Scene);
  79657. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79658. AddAttribute(name: string): CustomMaterial;
  79659. Fragment_Begin(shaderPart: string): CustomMaterial;
  79660. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79661. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79662. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79663. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79664. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79665. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79666. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79667. Vertex_Begin(shaderPart: string): CustomMaterial;
  79668. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79669. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79670. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79671. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79672. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79673. }
  79674. }
  79675. declare module BABYLON {
  79676. export class ShaderAlebdoParts {
  79677. constructor();
  79678. Fragment_Begin: string;
  79679. Fragment_Definitions: string;
  79680. Fragment_MainBegin: string;
  79681. Fragment_Custom_Albedo: string;
  79682. Fragment_Before_Lights: string;
  79683. Fragment_Custom_MetallicRoughness: string;
  79684. Fragment_Custom_MicroSurface: string;
  79685. Fragment_Before_Fog: string;
  79686. Fragment_Custom_Alpha: string;
  79687. Fragment_Before_FragColor: string;
  79688. Vertex_Begin: string;
  79689. Vertex_Definitions: string;
  79690. Vertex_MainBegin: string;
  79691. Vertex_Before_PositionUpdated: string;
  79692. Vertex_Before_NormalUpdated: string;
  79693. Vertex_MainEnd: string;
  79694. }
  79695. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79696. static ShaderIndexer: number;
  79697. CustomParts: ShaderAlebdoParts;
  79698. _isCreatedShader: boolean;
  79699. _createdShaderName: string;
  79700. _customUniform: string[];
  79701. _newUniforms: string[];
  79702. _newUniformInstances: any[];
  79703. _newSamplerInstances: BABYLON.Texture[];
  79704. _customAttributes: string[];
  79705. FragmentShader: string;
  79706. VertexShader: string;
  79707. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79708. ReviewUniform(name: string, arr: string[]): string[];
  79709. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79710. constructor(name: string, scene: BABYLON.Scene);
  79711. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79712. AddAttribute(name: string): PBRCustomMaterial;
  79713. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79714. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79715. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79716. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79717. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79718. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79719. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79720. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79721. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79722. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79723. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79724. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79725. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79726. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79727. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79728. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79729. }
  79730. }
  79731. declare module BABYLON {
  79732. /** @hidden */
  79733. export var firePixelShader: {
  79734. name: string;
  79735. shader: string;
  79736. };
  79737. }
  79738. declare module BABYLON {
  79739. /** @hidden */
  79740. export var fireVertexShader: {
  79741. name: string;
  79742. shader: string;
  79743. };
  79744. }
  79745. declare module BABYLON {
  79746. export class FireMaterial extends BABYLON.PushMaterial {
  79747. private _diffuseTexture;
  79748. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79749. private _distortionTexture;
  79750. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79751. private _opacityTexture;
  79752. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79753. diffuseColor: BABYLON.Color3;
  79754. speed: number;
  79755. private _scaledDiffuse;
  79756. private _lastTime;
  79757. constructor(name: string, scene: BABYLON.Scene);
  79758. needAlphaBlending(): boolean;
  79759. needAlphaTesting(): boolean;
  79760. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79761. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79763. getAnimatables(): BABYLON.IAnimatable[];
  79764. getActiveTextures(): BABYLON.BaseTexture[];
  79765. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79766. getClassName(): string;
  79767. dispose(forceDisposeEffect?: boolean): void;
  79768. clone(name: string): FireMaterial;
  79769. serialize(): any;
  79770. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79771. }
  79772. }
  79773. declare module BABYLON {
  79774. /** @hidden */
  79775. export var furPixelShader: {
  79776. name: string;
  79777. shader: string;
  79778. };
  79779. }
  79780. declare module BABYLON {
  79781. /** @hidden */
  79782. export var furVertexShader: {
  79783. name: string;
  79784. shader: string;
  79785. };
  79786. }
  79787. declare module BABYLON {
  79788. export class FurMaterial extends BABYLON.PushMaterial {
  79789. private _diffuseTexture;
  79790. diffuseTexture: BABYLON.BaseTexture;
  79791. private _heightTexture;
  79792. heightTexture: BABYLON.BaseTexture;
  79793. diffuseColor: BABYLON.Color3;
  79794. furLength: number;
  79795. furAngle: number;
  79796. furColor: BABYLON.Color3;
  79797. furOffset: number;
  79798. furSpacing: number;
  79799. furGravity: BABYLON.Vector3;
  79800. furSpeed: number;
  79801. furDensity: number;
  79802. furOcclusion: number;
  79803. furTexture: BABYLON.DynamicTexture;
  79804. private _disableLighting;
  79805. disableLighting: boolean;
  79806. private _maxSimultaneousLights;
  79807. maxSimultaneousLights: number;
  79808. highLevelFur: boolean;
  79809. _meshes: BABYLON.AbstractMesh[];
  79810. private _furTime;
  79811. constructor(name: string, scene: BABYLON.Scene);
  79812. get furTime(): number;
  79813. set furTime(furTime: number);
  79814. needAlphaBlending(): boolean;
  79815. needAlphaTesting(): boolean;
  79816. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79817. updateFur(): void;
  79818. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79819. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79820. getAnimatables(): BABYLON.IAnimatable[];
  79821. getActiveTextures(): BABYLON.BaseTexture[];
  79822. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79823. dispose(forceDisposeEffect?: boolean): void;
  79824. clone(name: string): FurMaterial;
  79825. serialize(): any;
  79826. getClassName(): string;
  79827. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79828. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79829. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79830. }
  79831. }
  79832. declare module BABYLON {
  79833. /** @hidden */
  79834. export var gradientPixelShader: {
  79835. name: string;
  79836. shader: string;
  79837. };
  79838. }
  79839. declare module BABYLON {
  79840. /** @hidden */
  79841. export var gradientVertexShader: {
  79842. name: string;
  79843. shader: string;
  79844. };
  79845. }
  79846. declare module BABYLON {
  79847. export class GradientMaterial extends BABYLON.PushMaterial {
  79848. private _maxSimultaneousLights;
  79849. maxSimultaneousLights: number;
  79850. topColor: BABYLON.Color3;
  79851. topColorAlpha: number;
  79852. bottomColor: BABYLON.Color3;
  79853. bottomColorAlpha: number;
  79854. offset: number;
  79855. scale: number;
  79856. smoothness: number;
  79857. private _disableLighting;
  79858. disableLighting: boolean;
  79859. constructor(name: string, scene: BABYLON.Scene);
  79860. needAlphaBlending(): boolean;
  79861. needAlphaTesting(): boolean;
  79862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79865. getAnimatables(): BABYLON.IAnimatable[];
  79866. dispose(forceDisposeEffect?: boolean): void;
  79867. clone(name: string): GradientMaterial;
  79868. serialize(): any;
  79869. getClassName(): string;
  79870. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79871. }
  79872. }
  79873. declare module BABYLON {
  79874. /** @hidden */
  79875. export var gridPixelShader: {
  79876. name: string;
  79877. shader: string;
  79878. };
  79879. }
  79880. declare module BABYLON {
  79881. /** @hidden */
  79882. export var gridVertexShader: {
  79883. name: string;
  79884. shader: string;
  79885. };
  79886. }
  79887. declare module BABYLON {
  79888. /**
  79889. * The grid materials allows you to wrap any shape with a grid.
  79890. * Colors are customizable.
  79891. */
  79892. export class GridMaterial extends BABYLON.PushMaterial {
  79893. /**
  79894. * Main color of the grid (e.g. between lines)
  79895. */
  79896. mainColor: BABYLON.Color3;
  79897. /**
  79898. * Color of the grid lines.
  79899. */
  79900. lineColor: BABYLON.Color3;
  79901. /**
  79902. * The scale of the grid compared to unit.
  79903. */
  79904. gridRatio: number;
  79905. /**
  79906. * Allows setting an offset for the grid lines.
  79907. */
  79908. gridOffset: BABYLON.Vector3;
  79909. /**
  79910. * The frequency of thicker lines.
  79911. */
  79912. majorUnitFrequency: number;
  79913. /**
  79914. * The visibility of minor units in the grid.
  79915. */
  79916. minorUnitVisibility: number;
  79917. /**
  79918. * The grid opacity outside of the lines.
  79919. */
  79920. opacity: number;
  79921. /**
  79922. * Determine RBG output is premultiplied by alpha value.
  79923. */
  79924. preMultiplyAlpha: boolean;
  79925. private _opacityTexture;
  79926. opacityTexture: BABYLON.BaseTexture;
  79927. private _gridControl;
  79928. /**
  79929. * constructor
  79930. * @param name The name given to the material in order to identify it afterwards.
  79931. * @param scene The scene the material is used in.
  79932. */
  79933. constructor(name: string, scene: BABYLON.Scene);
  79934. /**
  79935. * Returns wehter or not the grid requires alpha blending.
  79936. */
  79937. needAlphaBlending(): boolean;
  79938. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79939. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79940. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79941. /**
  79942. * Dispose the material and its associated resources.
  79943. * @param forceDisposeEffect will also dispose the used effect when true
  79944. */
  79945. dispose(forceDisposeEffect?: boolean): void;
  79946. clone(name: string): GridMaterial;
  79947. serialize(): any;
  79948. getClassName(): string;
  79949. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79950. }
  79951. }
  79952. declare module BABYLON {
  79953. /** @hidden */
  79954. export var lavaPixelShader: {
  79955. name: string;
  79956. shader: string;
  79957. };
  79958. }
  79959. declare module BABYLON {
  79960. /** @hidden */
  79961. export var lavaVertexShader: {
  79962. name: string;
  79963. shader: string;
  79964. };
  79965. }
  79966. declare module BABYLON {
  79967. export class LavaMaterial extends BABYLON.PushMaterial {
  79968. private _diffuseTexture;
  79969. diffuseTexture: BABYLON.BaseTexture;
  79970. noiseTexture: BABYLON.BaseTexture;
  79971. fogColor: BABYLON.Color3;
  79972. speed: number;
  79973. movingSpeed: number;
  79974. lowFrequencySpeed: number;
  79975. fogDensity: number;
  79976. private _lastTime;
  79977. diffuseColor: BABYLON.Color3;
  79978. private _disableLighting;
  79979. disableLighting: boolean;
  79980. private _unlit;
  79981. unlit: boolean;
  79982. private _maxSimultaneousLights;
  79983. maxSimultaneousLights: number;
  79984. private _scaledDiffuse;
  79985. constructor(name: string, scene: BABYLON.Scene);
  79986. needAlphaBlending(): boolean;
  79987. needAlphaTesting(): boolean;
  79988. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79989. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79990. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79991. getAnimatables(): BABYLON.IAnimatable[];
  79992. getActiveTextures(): BABYLON.BaseTexture[];
  79993. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79994. dispose(forceDisposeEffect?: boolean): void;
  79995. clone(name: string): LavaMaterial;
  79996. serialize(): any;
  79997. getClassName(): string;
  79998. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79999. }
  80000. }
  80001. declare module BABYLON {
  80002. /** @hidden */
  80003. export var mixPixelShader: {
  80004. name: string;
  80005. shader: string;
  80006. };
  80007. }
  80008. declare module BABYLON {
  80009. /** @hidden */
  80010. export var mixVertexShader: {
  80011. name: string;
  80012. shader: string;
  80013. };
  80014. }
  80015. declare module BABYLON {
  80016. export class MixMaterial extends BABYLON.PushMaterial {
  80017. /**
  80018. * Mix textures
  80019. */
  80020. private _mixTexture1;
  80021. mixTexture1: BABYLON.BaseTexture;
  80022. private _mixTexture2;
  80023. mixTexture2: BABYLON.BaseTexture;
  80024. /**
  80025. * Diffuse textures
  80026. */
  80027. private _diffuseTexture1;
  80028. diffuseTexture1: BABYLON.Texture;
  80029. private _diffuseTexture2;
  80030. diffuseTexture2: BABYLON.Texture;
  80031. private _diffuseTexture3;
  80032. diffuseTexture3: BABYLON.Texture;
  80033. private _diffuseTexture4;
  80034. diffuseTexture4: BABYLON.Texture;
  80035. private _diffuseTexture5;
  80036. diffuseTexture5: BABYLON.Texture;
  80037. private _diffuseTexture6;
  80038. diffuseTexture6: BABYLON.Texture;
  80039. private _diffuseTexture7;
  80040. diffuseTexture7: BABYLON.Texture;
  80041. private _diffuseTexture8;
  80042. diffuseTexture8: BABYLON.Texture;
  80043. /**
  80044. * Uniforms
  80045. */
  80046. diffuseColor: BABYLON.Color3;
  80047. specularColor: BABYLON.Color3;
  80048. specularPower: number;
  80049. private _disableLighting;
  80050. disableLighting: boolean;
  80051. private _maxSimultaneousLights;
  80052. maxSimultaneousLights: number;
  80053. constructor(name: string, scene: BABYLON.Scene);
  80054. needAlphaBlending(): boolean;
  80055. needAlphaTesting(): boolean;
  80056. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80057. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80058. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80059. getAnimatables(): BABYLON.IAnimatable[];
  80060. getActiveTextures(): BABYLON.BaseTexture[];
  80061. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80062. dispose(forceDisposeEffect?: boolean): void;
  80063. clone(name: string): MixMaterial;
  80064. serialize(): any;
  80065. getClassName(): string;
  80066. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80067. }
  80068. }
  80069. declare module BABYLON {
  80070. /** @hidden */
  80071. export var normalPixelShader: {
  80072. name: string;
  80073. shader: string;
  80074. };
  80075. }
  80076. declare module BABYLON {
  80077. /** @hidden */
  80078. export var normalVertexShader: {
  80079. name: string;
  80080. shader: string;
  80081. };
  80082. }
  80083. declare module BABYLON {
  80084. export class NormalMaterial extends BABYLON.PushMaterial {
  80085. private _diffuseTexture;
  80086. diffuseTexture: BABYLON.BaseTexture;
  80087. diffuseColor: BABYLON.Color3;
  80088. private _disableLighting;
  80089. disableLighting: boolean;
  80090. private _maxSimultaneousLights;
  80091. maxSimultaneousLights: number;
  80092. constructor(name: string, scene: BABYLON.Scene);
  80093. needAlphaBlending(): boolean;
  80094. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80095. needAlphaTesting(): boolean;
  80096. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80097. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80098. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80099. getAnimatables(): BABYLON.IAnimatable[];
  80100. getActiveTextures(): BABYLON.BaseTexture[];
  80101. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80102. dispose(forceDisposeEffect?: boolean): void;
  80103. clone(name: string): NormalMaterial;
  80104. serialize(): any;
  80105. getClassName(): string;
  80106. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80107. }
  80108. }
  80109. declare module BABYLON {
  80110. /** @hidden */
  80111. export var shadowOnlyPixelShader: {
  80112. name: string;
  80113. shader: string;
  80114. };
  80115. }
  80116. declare module BABYLON {
  80117. /** @hidden */
  80118. export var shadowOnlyVertexShader: {
  80119. name: string;
  80120. shader: string;
  80121. };
  80122. }
  80123. declare module BABYLON {
  80124. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80125. private _activeLight;
  80126. constructor(name: string, scene: BABYLON.Scene);
  80127. shadowColor: BABYLON.Color3;
  80128. needAlphaBlending(): boolean;
  80129. needAlphaTesting(): boolean;
  80130. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80131. get activeLight(): BABYLON.IShadowLight;
  80132. set activeLight(light: BABYLON.IShadowLight);
  80133. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80134. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80135. clone(name: string): ShadowOnlyMaterial;
  80136. serialize(): any;
  80137. getClassName(): string;
  80138. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80139. }
  80140. }
  80141. declare module BABYLON {
  80142. /** @hidden */
  80143. export var simplePixelShader: {
  80144. name: string;
  80145. shader: string;
  80146. };
  80147. }
  80148. declare module BABYLON {
  80149. /** @hidden */
  80150. export var simpleVertexShader: {
  80151. name: string;
  80152. shader: string;
  80153. };
  80154. }
  80155. declare module BABYLON {
  80156. export class SimpleMaterial extends BABYLON.PushMaterial {
  80157. private _diffuseTexture;
  80158. diffuseTexture: BABYLON.BaseTexture;
  80159. diffuseColor: BABYLON.Color3;
  80160. private _disableLighting;
  80161. disableLighting: boolean;
  80162. private _maxSimultaneousLights;
  80163. maxSimultaneousLights: number;
  80164. constructor(name: string, scene: BABYLON.Scene);
  80165. needAlphaBlending(): boolean;
  80166. needAlphaTesting(): boolean;
  80167. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80168. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80169. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80170. getAnimatables(): BABYLON.IAnimatable[];
  80171. getActiveTextures(): BABYLON.BaseTexture[];
  80172. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80173. dispose(forceDisposeEffect?: boolean): void;
  80174. clone(name: string): SimpleMaterial;
  80175. serialize(): any;
  80176. getClassName(): string;
  80177. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80178. }
  80179. }
  80180. declare module BABYLON {
  80181. /** @hidden */
  80182. export var skyPixelShader: {
  80183. name: string;
  80184. shader: string;
  80185. };
  80186. }
  80187. declare module BABYLON {
  80188. /** @hidden */
  80189. export var skyVertexShader: {
  80190. name: string;
  80191. shader: string;
  80192. };
  80193. }
  80194. declare module BABYLON {
  80195. /**
  80196. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80197. * @see https://doc.babylonjs.com/extensions/sky
  80198. */
  80199. export class SkyMaterial extends BABYLON.PushMaterial {
  80200. /**
  80201. * Defines the overall luminance of sky in interval ]0, 1[.
  80202. */
  80203. luminance: number;
  80204. /**
  80205. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80206. */
  80207. turbidity: number;
  80208. /**
  80209. * Defines the sky appearance (light intensity).
  80210. */
  80211. rayleigh: number;
  80212. /**
  80213. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80214. */
  80215. mieCoefficient: number;
  80216. /**
  80217. * Defines the amount of haze particles following the Mie scattering theory.
  80218. */
  80219. mieDirectionalG: number;
  80220. /**
  80221. * Defines the distance of the sun according to the active scene camera.
  80222. */
  80223. distance: number;
  80224. /**
  80225. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80226. * "inclined".
  80227. */
  80228. inclination: number;
  80229. /**
  80230. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80231. * an object direction and a reference direction.
  80232. */
  80233. azimuth: number;
  80234. /**
  80235. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80236. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80237. */
  80238. sunPosition: BABYLON.Vector3;
  80239. /**
  80240. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80241. * .sunPosition property.
  80242. */
  80243. useSunPosition: boolean;
  80244. /**
  80245. * Defines an offset vector used to get a horizon offset.
  80246. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80247. */
  80248. cameraOffset: BABYLON.Vector3;
  80249. private _cameraPosition;
  80250. /**
  80251. * Instantiates a new sky material.
  80252. * This material allows to create dynamic and texture free
  80253. * effects for skyboxes by taking care of the atmosphere state.
  80254. * @see https://doc.babylonjs.com/extensions/sky
  80255. * @param name Define the name of the material in the scene
  80256. * @param scene Define the scene the material belong to
  80257. */
  80258. constructor(name: string, scene: BABYLON.Scene);
  80259. /**
  80260. * Specifies if the material will require alpha blending
  80261. * @returns a boolean specifying if alpha blending is needed
  80262. */
  80263. needAlphaBlending(): boolean;
  80264. /**
  80265. * Specifies if this material should be rendered in alpha test mode
  80266. * @returns false as the sky material doesn't need alpha testing.
  80267. */
  80268. needAlphaTesting(): boolean;
  80269. /**
  80270. * Get the texture used for alpha test purpose.
  80271. * @returns null as the sky material has no texture.
  80272. */
  80273. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80274. /**
  80275. * Get if the submesh is ready to be used and all its information available.
  80276. * Child classes can use it to update shaders
  80277. * @param mesh defines the mesh to check
  80278. * @param subMesh defines which submesh to check
  80279. * @param useInstances specifies that instances should be used
  80280. * @returns a boolean indicating that the submesh is ready or not
  80281. */
  80282. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80283. /**
  80284. * Binds the submesh to this material by preparing the effect and shader to draw
  80285. * @param world defines the world transformation matrix
  80286. * @param mesh defines the mesh containing the submesh
  80287. * @param subMesh defines the submesh to bind the material to
  80288. */
  80289. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80290. /**
  80291. * Get the list of animatables in the material.
  80292. * @returns the list of animatables object used in the material
  80293. */
  80294. getAnimatables(): BABYLON.IAnimatable[];
  80295. /**
  80296. * Disposes the material
  80297. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80298. */
  80299. dispose(forceDisposeEffect?: boolean): void;
  80300. /**
  80301. * Makes a duplicate of the material, and gives it a new name
  80302. * @param name defines the new name for the duplicated material
  80303. * @returns the cloned material
  80304. */
  80305. clone(name: string): SkyMaterial;
  80306. /**
  80307. * Serializes this material in a JSON representation
  80308. * @returns the serialized material object
  80309. */
  80310. serialize(): any;
  80311. /**
  80312. * Gets the current class name of the material e.g. "SkyMaterial"
  80313. * Mainly use in serialization.
  80314. * @returns the class name
  80315. */
  80316. getClassName(): string;
  80317. /**
  80318. * Creates a sky material from parsed material data
  80319. * @param source defines the JSON representation of the material
  80320. * @param scene defines the hosting scene
  80321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80322. * @returns a new sky material
  80323. */
  80324. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80325. }
  80326. }
  80327. declare module BABYLON {
  80328. /** @hidden */
  80329. export var terrainPixelShader: {
  80330. name: string;
  80331. shader: string;
  80332. };
  80333. }
  80334. declare module BABYLON {
  80335. /** @hidden */
  80336. export var terrainVertexShader: {
  80337. name: string;
  80338. shader: string;
  80339. };
  80340. }
  80341. declare module BABYLON {
  80342. export class TerrainMaterial extends BABYLON.PushMaterial {
  80343. private _mixTexture;
  80344. mixTexture: BABYLON.BaseTexture;
  80345. private _diffuseTexture1;
  80346. diffuseTexture1: BABYLON.Texture;
  80347. private _diffuseTexture2;
  80348. diffuseTexture2: BABYLON.Texture;
  80349. private _diffuseTexture3;
  80350. diffuseTexture3: BABYLON.Texture;
  80351. private _bumpTexture1;
  80352. bumpTexture1: BABYLON.Texture;
  80353. private _bumpTexture2;
  80354. bumpTexture2: BABYLON.Texture;
  80355. private _bumpTexture3;
  80356. bumpTexture3: BABYLON.Texture;
  80357. diffuseColor: BABYLON.Color3;
  80358. specularColor: BABYLON.Color3;
  80359. specularPower: number;
  80360. private _disableLighting;
  80361. disableLighting: boolean;
  80362. private _maxSimultaneousLights;
  80363. maxSimultaneousLights: number;
  80364. constructor(name: string, scene: BABYLON.Scene);
  80365. needAlphaBlending(): boolean;
  80366. needAlphaTesting(): boolean;
  80367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80370. getAnimatables(): BABYLON.IAnimatable[];
  80371. getActiveTextures(): BABYLON.BaseTexture[];
  80372. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80373. dispose(forceDisposeEffect?: boolean): void;
  80374. clone(name: string): TerrainMaterial;
  80375. serialize(): any;
  80376. getClassName(): string;
  80377. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80378. }
  80379. }
  80380. declare module BABYLON {
  80381. /** @hidden */
  80382. export var triplanarPixelShader: {
  80383. name: string;
  80384. shader: string;
  80385. };
  80386. }
  80387. declare module BABYLON {
  80388. /** @hidden */
  80389. export var triplanarVertexShader: {
  80390. name: string;
  80391. shader: string;
  80392. };
  80393. }
  80394. declare module BABYLON {
  80395. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80396. mixTexture: BABYLON.BaseTexture;
  80397. private _diffuseTextureX;
  80398. diffuseTextureX: BABYLON.BaseTexture;
  80399. private _diffuseTextureY;
  80400. diffuseTextureY: BABYLON.BaseTexture;
  80401. private _diffuseTextureZ;
  80402. diffuseTextureZ: BABYLON.BaseTexture;
  80403. private _normalTextureX;
  80404. normalTextureX: BABYLON.BaseTexture;
  80405. private _normalTextureY;
  80406. normalTextureY: BABYLON.BaseTexture;
  80407. private _normalTextureZ;
  80408. normalTextureZ: BABYLON.BaseTexture;
  80409. tileSize: number;
  80410. diffuseColor: BABYLON.Color3;
  80411. specularColor: BABYLON.Color3;
  80412. specularPower: number;
  80413. private _disableLighting;
  80414. disableLighting: boolean;
  80415. private _maxSimultaneousLights;
  80416. maxSimultaneousLights: number;
  80417. constructor(name: string, scene: BABYLON.Scene);
  80418. needAlphaBlending(): boolean;
  80419. needAlphaTesting(): boolean;
  80420. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80423. getAnimatables(): BABYLON.IAnimatable[];
  80424. getActiveTextures(): BABYLON.BaseTexture[];
  80425. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80426. dispose(forceDisposeEffect?: boolean): void;
  80427. clone(name: string): TriPlanarMaterial;
  80428. serialize(): any;
  80429. getClassName(): string;
  80430. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80431. }
  80432. }
  80433. declare module BABYLON {
  80434. /** @hidden */
  80435. export var waterPixelShader: {
  80436. name: string;
  80437. shader: string;
  80438. };
  80439. }
  80440. declare module BABYLON {
  80441. /** @hidden */
  80442. export var waterVertexShader: {
  80443. name: string;
  80444. shader: string;
  80445. };
  80446. }
  80447. declare module BABYLON {
  80448. export class WaterMaterial extends BABYLON.PushMaterial {
  80449. renderTargetSize: BABYLON.Vector2;
  80450. private _bumpTexture;
  80451. bumpTexture: BABYLON.BaseTexture;
  80452. diffuseColor: BABYLON.Color3;
  80453. specularColor: BABYLON.Color3;
  80454. specularPower: number;
  80455. private _disableLighting;
  80456. disableLighting: boolean;
  80457. private _maxSimultaneousLights;
  80458. maxSimultaneousLights: number;
  80459. /**
  80460. * @param {number}: Represents the wind force
  80461. */
  80462. windForce: number;
  80463. /**
  80464. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80465. */
  80466. windDirection: BABYLON.Vector2;
  80467. /**
  80468. * @param {number}: Wave height, represents the height of the waves
  80469. */
  80470. waveHeight: number;
  80471. /**
  80472. * @param {number}: Bump height, represents the bump height related to the bump map
  80473. */
  80474. bumpHeight: number;
  80475. /**
  80476. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80477. */
  80478. private _bumpSuperimpose;
  80479. bumpSuperimpose: boolean;
  80480. /**
  80481. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80482. */
  80483. private _fresnelSeparate;
  80484. fresnelSeparate: boolean;
  80485. /**
  80486. * @param {boolean}: bump Waves modify the reflection.
  80487. */
  80488. private _bumpAffectsReflection;
  80489. bumpAffectsReflection: boolean;
  80490. /**
  80491. * @param {number}: The water color blended with the refraction (near)
  80492. */
  80493. waterColor: BABYLON.Color3;
  80494. /**
  80495. * @param {number}: The blend factor related to the water color
  80496. */
  80497. colorBlendFactor: number;
  80498. /**
  80499. * @param {number}: The water color blended with the reflection (far)
  80500. */
  80501. waterColor2: BABYLON.Color3;
  80502. /**
  80503. * @param {number}: The blend factor related to the water color (reflection, far)
  80504. */
  80505. colorBlendFactor2: number;
  80506. /**
  80507. * @param {number}: Represents the maximum length of a wave
  80508. */
  80509. waveLength: number;
  80510. /**
  80511. * @param {number}: Defines the waves speed
  80512. */
  80513. waveSpeed: number;
  80514. /**
  80515. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80516. * will avoid calculating useless pixels in the pixel shader of the water material.
  80517. */
  80518. disableClipPlane: boolean;
  80519. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80520. private _mesh;
  80521. private _refractionRTT;
  80522. private _reflectionRTT;
  80523. private _reflectionTransform;
  80524. private _lastTime;
  80525. private _lastDeltaTime;
  80526. private _useLogarithmicDepth;
  80527. private _waitingRenderList;
  80528. private _imageProcessingConfiguration;
  80529. private _imageProcessingObserver;
  80530. /**
  80531. * Gets a boolean indicating that current material needs to register RTT
  80532. */
  80533. get hasRenderTargetTextures(): boolean;
  80534. /**
  80535. * Constructor
  80536. */
  80537. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80538. get useLogarithmicDepth(): boolean;
  80539. set useLogarithmicDepth(value: boolean);
  80540. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80541. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80542. addToRenderList(node: any): void;
  80543. enableRenderTargets(enable: boolean): void;
  80544. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80545. get renderTargetsEnabled(): boolean;
  80546. needAlphaBlending(): boolean;
  80547. needAlphaTesting(): boolean;
  80548. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80549. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80550. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80551. private _createRenderTargets;
  80552. getAnimatables(): BABYLON.IAnimatable[];
  80553. getActiveTextures(): BABYLON.BaseTexture[];
  80554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80555. dispose(forceDisposeEffect?: boolean): void;
  80556. clone(name: string): WaterMaterial;
  80557. serialize(): any;
  80558. getClassName(): string;
  80559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80560. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. /** @hidden */
  80565. export var asciiartPixelShader: {
  80566. name: string;
  80567. shader: string;
  80568. };
  80569. }
  80570. declare module BABYLON {
  80571. /**
  80572. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80573. *
  80574. * It basically takes care rendering the font front the given font size to a texture.
  80575. * This is used later on in the postprocess.
  80576. */
  80577. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80578. private _font;
  80579. private _text;
  80580. private _charSize;
  80581. /**
  80582. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80583. */
  80584. get charSize(): number;
  80585. /**
  80586. * Create a new instance of the Ascii Art FontTexture class
  80587. * @param name the name of the texture
  80588. * @param font the font to use, use the W3C CSS notation
  80589. * @param text the caracter set to use in the rendering.
  80590. * @param scene the scene that owns the texture
  80591. */
  80592. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80593. /**
  80594. * Gets the max char width of a font.
  80595. * @param font the font to use, use the W3C CSS notation
  80596. * @return the max char width
  80597. */
  80598. private getFontWidth;
  80599. /**
  80600. * Gets the max char height of a font.
  80601. * @param font the font to use, use the W3C CSS notation
  80602. * @return the max char height
  80603. */
  80604. private getFontHeight;
  80605. /**
  80606. * Clones the current AsciiArtTexture.
  80607. * @return the clone of the texture.
  80608. */
  80609. clone(): AsciiArtFontTexture;
  80610. /**
  80611. * Parses a json object representing the texture and returns an instance of it.
  80612. * @param source the source JSON representation
  80613. * @param scene the scene to create the texture for
  80614. * @return the parsed texture
  80615. */
  80616. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80617. }
  80618. /**
  80619. * Option available in the Ascii Art Post Process.
  80620. */
  80621. export interface IAsciiArtPostProcessOptions {
  80622. /**
  80623. * The font to use following the w3c font definition.
  80624. */
  80625. font?: string;
  80626. /**
  80627. * The character set to use in the postprocess.
  80628. */
  80629. characterSet?: string;
  80630. /**
  80631. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80632. * This number is defined between 0 and 1;
  80633. */
  80634. mixToTile?: number;
  80635. /**
  80636. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80637. * This number is defined between 0 and 1;
  80638. */
  80639. mixToNormal?: number;
  80640. }
  80641. /**
  80642. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80643. *
  80644. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80645. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80646. */
  80647. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80648. /**
  80649. * The font texture used to render the char in the post process.
  80650. */
  80651. private _asciiArtFontTexture;
  80652. /**
  80653. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80654. * This number is defined between 0 and 1;
  80655. */
  80656. mixToTile: number;
  80657. /**
  80658. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80659. * This number is defined between 0 and 1;
  80660. */
  80661. mixToNormal: number;
  80662. /**
  80663. * Instantiates a new Ascii Art Post Process.
  80664. * @param name the name to give to the postprocess
  80665. * @camera the camera to apply the post process to.
  80666. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80667. */
  80668. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80669. }
  80670. }
  80671. declare module BABYLON {
  80672. /** @hidden */
  80673. export var digitalrainPixelShader: {
  80674. name: string;
  80675. shader: string;
  80676. };
  80677. }
  80678. declare module BABYLON {
  80679. /**
  80680. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80681. *
  80682. * It basically takes care rendering the font front the given font size to a texture.
  80683. * This is used later on in the postprocess.
  80684. */
  80685. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80686. private _font;
  80687. private _text;
  80688. private _charSize;
  80689. /**
  80690. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80691. */
  80692. get charSize(): number;
  80693. /**
  80694. * Create a new instance of the Digital Rain FontTexture class
  80695. * @param name the name of the texture
  80696. * @param font the font to use, use the W3C CSS notation
  80697. * @param text the caracter set to use in the rendering.
  80698. * @param scene the scene that owns the texture
  80699. */
  80700. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80701. /**
  80702. * Gets the max char width of a font.
  80703. * @param font the font to use, use the W3C CSS notation
  80704. * @return the max char width
  80705. */
  80706. private getFontWidth;
  80707. /**
  80708. * Gets the max char height of a font.
  80709. * @param font the font to use, use the W3C CSS notation
  80710. * @return the max char height
  80711. */
  80712. private getFontHeight;
  80713. /**
  80714. * Clones the current DigitalRainFontTexture.
  80715. * @return the clone of the texture.
  80716. */
  80717. clone(): DigitalRainFontTexture;
  80718. /**
  80719. * Parses a json object representing the texture and returns an instance of it.
  80720. * @param source the source JSON representation
  80721. * @param scene the scene to create the texture for
  80722. * @return the parsed texture
  80723. */
  80724. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80725. }
  80726. /**
  80727. * Option available in the Digital Rain Post Process.
  80728. */
  80729. export interface IDigitalRainPostProcessOptions {
  80730. /**
  80731. * The font to use following the w3c font definition.
  80732. */
  80733. font?: string;
  80734. /**
  80735. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80736. * This number is defined between 0 and 1;
  80737. */
  80738. mixToTile?: number;
  80739. /**
  80740. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80741. * This number is defined between 0 and 1;
  80742. */
  80743. mixToNormal?: number;
  80744. }
  80745. /**
  80746. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80747. *
  80748. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80749. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80750. */
  80751. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80752. /**
  80753. * The font texture used to render the char in the post process.
  80754. */
  80755. private _digitalRainFontTexture;
  80756. /**
  80757. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80758. * This number is defined between 0 and 1;
  80759. */
  80760. mixToTile: number;
  80761. /**
  80762. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80763. * This number is defined between 0 and 1;
  80764. */
  80765. mixToNormal: number;
  80766. /**
  80767. * Instantiates a new Digital Rain Post Process.
  80768. * @param name the name to give to the postprocess
  80769. * @camera the camera to apply the post process to.
  80770. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80771. */
  80772. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80773. }
  80774. }
  80775. declare module BABYLON {
  80776. /** @hidden */
  80777. export var brickProceduralTexturePixelShader: {
  80778. name: string;
  80779. shader: string;
  80780. };
  80781. }
  80782. declare module BABYLON {
  80783. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80784. private _numberOfBricksHeight;
  80785. private _numberOfBricksWidth;
  80786. private _jointColor;
  80787. private _brickColor;
  80788. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80789. updateShaderUniforms(): void;
  80790. get numberOfBricksHeight(): number;
  80791. set numberOfBricksHeight(value: number);
  80792. get numberOfBricksWidth(): number;
  80793. set numberOfBricksWidth(value: number);
  80794. get jointColor(): BABYLON.Color3;
  80795. set jointColor(value: BABYLON.Color3);
  80796. get brickColor(): BABYLON.Color3;
  80797. set brickColor(value: BABYLON.Color3);
  80798. /**
  80799. * Serializes this brick procedural texture
  80800. * @returns a serialized brick procedural texture object
  80801. */
  80802. serialize(): any;
  80803. /**
  80804. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80805. * @param parsedTexture defines parsed texture data
  80806. * @param scene defines the current scene
  80807. * @param rootUrl defines the root URL containing brick procedural texture information
  80808. * @returns a parsed Brick Procedural BABYLON.Texture
  80809. */
  80810. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80811. }
  80812. }
  80813. declare module BABYLON {
  80814. /** @hidden */
  80815. export var cloudProceduralTexturePixelShader: {
  80816. name: string;
  80817. shader: string;
  80818. };
  80819. }
  80820. declare module BABYLON {
  80821. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80822. private _skyColor;
  80823. private _cloudColor;
  80824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80825. updateShaderUniforms(): void;
  80826. get skyColor(): BABYLON.Color4;
  80827. set skyColor(value: BABYLON.Color4);
  80828. get cloudColor(): BABYLON.Color4;
  80829. set cloudColor(value: BABYLON.Color4);
  80830. /**
  80831. * Serializes this cloud procedural texture
  80832. * @returns a serialized cloud procedural texture object
  80833. */
  80834. serialize(): any;
  80835. /**
  80836. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80837. * @param parsedTexture defines parsed texture data
  80838. * @param scene defines the current scene
  80839. * @param rootUrl defines the root URL containing cloud procedural texture information
  80840. * @returns a parsed Cloud Procedural BABYLON.Texture
  80841. */
  80842. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80843. }
  80844. }
  80845. declare module BABYLON {
  80846. /** @hidden */
  80847. export var fireProceduralTexturePixelShader: {
  80848. name: string;
  80849. shader: string;
  80850. };
  80851. }
  80852. declare module BABYLON {
  80853. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80854. private _time;
  80855. private _speed;
  80856. private _autoGenerateTime;
  80857. private _fireColors;
  80858. private _alphaThreshold;
  80859. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80860. updateShaderUniforms(): void;
  80861. render(useCameraPostProcess?: boolean): void;
  80862. static get PurpleFireColors(): BABYLON.Color3[];
  80863. static get GreenFireColors(): BABYLON.Color3[];
  80864. static get RedFireColors(): BABYLON.Color3[];
  80865. static get BlueFireColors(): BABYLON.Color3[];
  80866. get autoGenerateTime(): boolean;
  80867. set autoGenerateTime(value: boolean);
  80868. get fireColors(): BABYLON.Color3[];
  80869. set fireColors(value: BABYLON.Color3[]);
  80870. get time(): number;
  80871. set time(value: number);
  80872. get speed(): BABYLON.Vector2;
  80873. set speed(value: BABYLON.Vector2);
  80874. get alphaThreshold(): number;
  80875. set alphaThreshold(value: number);
  80876. /**
  80877. * Serializes this fire procedural texture
  80878. * @returns a serialized fire procedural texture object
  80879. */
  80880. serialize(): any;
  80881. /**
  80882. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80883. * @param parsedTexture defines parsed texture data
  80884. * @param scene defines the current scene
  80885. * @param rootUrl defines the root URL containing fire procedural texture information
  80886. * @returns a parsed Fire Procedural BABYLON.Texture
  80887. */
  80888. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80889. }
  80890. }
  80891. declare module BABYLON {
  80892. /** @hidden */
  80893. export var grassProceduralTexturePixelShader: {
  80894. name: string;
  80895. shader: string;
  80896. };
  80897. }
  80898. declare module BABYLON {
  80899. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80900. private _grassColors;
  80901. private _groundColor;
  80902. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80903. updateShaderUniforms(): void;
  80904. get grassColors(): BABYLON.Color3[];
  80905. set grassColors(value: BABYLON.Color3[]);
  80906. get groundColor(): BABYLON.Color3;
  80907. set groundColor(value: BABYLON.Color3);
  80908. /**
  80909. * Serializes this grass procedural texture
  80910. * @returns a serialized grass procedural texture object
  80911. */
  80912. serialize(): any;
  80913. /**
  80914. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80915. * @param parsedTexture defines parsed texture data
  80916. * @param scene defines the current scene
  80917. * @param rootUrl defines the root URL containing grass procedural texture information
  80918. * @returns a parsed Grass Procedural BABYLON.Texture
  80919. */
  80920. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80921. }
  80922. }
  80923. declare module BABYLON {
  80924. /** @hidden */
  80925. export var marbleProceduralTexturePixelShader: {
  80926. name: string;
  80927. shader: string;
  80928. };
  80929. }
  80930. declare module BABYLON {
  80931. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80932. private _numberOfTilesHeight;
  80933. private _numberOfTilesWidth;
  80934. private _amplitude;
  80935. private _jointColor;
  80936. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80937. updateShaderUniforms(): void;
  80938. get numberOfTilesHeight(): number;
  80939. set numberOfTilesHeight(value: number);
  80940. get amplitude(): number;
  80941. set amplitude(value: number);
  80942. get numberOfTilesWidth(): number;
  80943. set numberOfTilesWidth(value: number);
  80944. get jointColor(): BABYLON.Color3;
  80945. set jointColor(value: BABYLON.Color3);
  80946. /**
  80947. * Serializes this marble procedural texture
  80948. * @returns a serialized marble procedural texture object
  80949. */
  80950. serialize(): any;
  80951. /**
  80952. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80953. * @param parsedTexture defines parsed texture data
  80954. * @param scene defines the current scene
  80955. * @param rootUrl defines the root URL containing marble procedural texture information
  80956. * @returns a parsed Marble Procedural BABYLON.Texture
  80957. */
  80958. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80959. }
  80960. }
  80961. declare module BABYLON {
  80962. /** @hidden */
  80963. export var normalMapProceduralTexturePixelShader: {
  80964. name: string;
  80965. shader: string;
  80966. };
  80967. }
  80968. declare module BABYLON {
  80969. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80970. private _baseTexture;
  80971. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80972. updateShaderUniforms(): void;
  80973. render(useCameraPostProcess?: boolean): void;
  80974. resize(size: any, generateMipMaps: any): void;
  80975. get baseTexture(): BABYLON.Texture;
  80976. set baseTexture(texture: BABYLON.Texture);
  80977. /**
  80978. * Serializes this normal map procedural texture
  80979. * @returns a serialized normal map procedural texture object
  80980. */
  80981. serialize(): any;
  80982. /**
  80983. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80984. * @param parsedTexture defines parsed texture data
  80985. * @param scene defines the current scene
  80986. * @param rootUrl defines the root URL containing normal map procedural texture information
  80987. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80988. */
  80989. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80990. }
  80991. }
  80992. declare module BABYLON {
  80993. /** @hidden */
  80994. export var perlinNoiseProceduralTexturePixelShader: {
  80995. name: string;
  80996. shader: string;
  80997. };
  80998. }
  80999. declare module BABYLON {
  81000. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81001. time: number;
  81002. timeScale: number;
  81003. translationSpeed: number;
  81004. private _currentTranslation;
  81005. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81006. updateShaderUniforms(): void;
  81007. render(useCameraPostProcess?: boolean): void;
  81008. resize(size: any, generateMipMaps: any): void;
  81009. /**
  81010. * Serializes this perlin noise procedural texture
  81011. * @returns a serialized perlin noise procedural texture object
  81012. */
  81013. serialize(): any;
  81014. /**
  81015. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81016. * @param parsedTexture defines parsed texture data
  81017. * @param scene defines the current scene
  81018. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81019. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81020. */
  81021. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81022. }
  81023. }
  81024. declare module BABYLON {
  81025. /** @hidden */
  81026. export var roadProceduralTexturePixelShader: {
  81027. name: string;
  81028. shader: string;
  81029. };
  81030. }
  81031. declare module BABYLON {
  81032. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81033. private _roadColor;
  81034. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81035. updateShaderUniforms(): void;
  81036. get roadColor(): BABYLON.Color3;
  81037. set roadColor(value: BABYLON.Color3);
  81038. /**
  81039. * Serializes this road procedural texture
  81040. * @returns a serialized road procedural texture object
  81041. */
  81042. serialize(): any;
  81043. /**
  81044. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81045. * @param parsedTexture defines parsed texture data
  81046. * @param scene defines the current scene
  81047. * @param rootUrl defines the root URL containing road procedural texture information
  81048. * @returns a parsed Road Procedural BABYLON.Texture
  81049. */
  81050. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81051. }
  81052. }
  81053. declare module BABYLON {
  81054. /** @hidden */
  81055. export var starfieldProceduralTexturePixelShader: {
  81056. name: string;
  81057. shader: string;
  81058. };
  81059. }
  81060. declare module BABYLON {
  81061. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81062. private _time;
  81063. private _alpha;
  81064. private _beta;
  81065. private _zoom;
  81066. private _formuparam;
  81067. private _stepsize;
  81068. private _tile;
  81069. private _brightness;
  81070. private _darkmatter;
  81071. private _distfading;
  81072. private _saturation;
  81073. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81074. updateShaderUniforms(): void;
  81075. get time(): number;
  81076. set time(value: number);
  81077. get alpha(): number;
  81078. set alpha(value: number);
  81079. get beta(): number;
  81080. set beta(value: number);
  81081. get formuparam(): number;
  81082. set formuparam(value: number);
  81083. get stepsize(): number;
  81084. set stepsize(value: number);
  81085. get zoom(): number;
  81086. set zoom(value: number);
  81087. get tile(): number;
  81088. set tile(value: number);
  81089. get brightness(): number;
  81090. set brightness(value: number);
  81091. get darkmatter(): number;
  81092. set darkmatter(value: number);
  81093. get distfading(): number;
  81094. set distfading(value: number);
  81095. get saturation(): number;
  81096. set saturation(value: number);
  81097. /**
  81098. * Serializes this starfield procedural texture
  81099. * @returns a serialized starfield procedural texture object
  81100. */
  81101. serialize(): any;
  81102. /**
  81103. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81104. * @param parsedTexture defines parsed texture data
  81105. * @param scene defines the current scene
  81106. * @param rootUrl defines the root URL containing startfield procedural texture information
  81107. * @returns a parsed Starfield Procedural BABYLON.Texture
  81108. */
  81109. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81110. }
  81111. }
  81112. declare module BABYLON {
  81113. /** @hidden */
  81114. export var woodProceduralTexturePixelShader: {
  81115. name: string;
  81116. shader: string;
  81117. };
  81118. }
  81119. declare module BABYLON {
  81120. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81121. private _ampScale;
  81122. private _woodColor;
  81123. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81124. updateShaderUniforms(): void;
  81125. get ampScale(): number;
  81126. set ampScale(value: number);
  81127. get woodColor(): BABYLON.Color3;
  81128. set woodColor(value: BABYLON.Color3);
  81129. /**
  81130. * Serializes this wood procedural texture
  81131. * @returns a serialized wood procedural texture object
  81132. */
  81133. serialize(): any;
  81134. /**
  81135. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81136. * @param parsedTexture defines parsed texture data
  81137. * @param scene defines the current scene
  81138. * @param rootUrl defines the root URL containing wood procedural texture information
  81139. * @returns a parsed Wood Procedural BABYLON.Texture
  81140. */
  81141. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81142. }
  81143. }